Re: next round: glib thread safety proposal



Hi, Jeff

> > > Take a look at my half-baked implementation.  Check out
> > > GLIB_1_1_4_THREADS branch.  It includes pthread.h the Right Way(IMHO).
> > > I didn't get very far with this, just made a few modules thread-safe.
> >
> > I already did, but we can't just use pthread.h, because it has got to be
> > protable, thats what its all about....
> 
> My point was more that I included pthread.h when it was autodetected
> at configure time, into glibconfig.h.  You can do the same with
> cthreads.h or whatever.

In my patch, pthread.h is included into glibconfig.h as well.

> > > Is this an issue?  I've always handled this with logic.  If a piece of
> > > data doesn't belong on the thread's stack, I stick it into the main
> > > dataspace while ensuring only that particular thread "knows" about it.
> 
> > yes, but how can that thread know about it.
> 
> Through the logic I code into the programs.  It's quite simple...
> 
> > Thats what thread specific
> > data means. you have a global key, shared by all threads and if you 
> > query
> > with that key, every thread gets its own data location. that is kind of
> > a
> > resemblence of static vars, only with the obviuos advantage, that every
> > thread has its own.
> 
> Can you give me a concrete example of where this would be useful?
> If each thread needs its own data location, I g_malloc it.  If each
> thread needs access to a global structure, I wrap it in a mutex.
>

I have a function, that uses a per thread memeory for certain objects in a
list.

g_thread_specific list;

do_it( gpointer object ) 
{
  GList *the_list = g_thread_specific_get(list);
  g_list_prepend(the_list, object);
}

How can the thread know about its list other than that? (Without the list
being an agrument, that is)

Bye,
Sebastian
-- 
+--------------============####################============--------------+
| Sebastian Wilhelmi, Institute for Computer Design and Fault Tolerance, |
| University of Karlsruhe;  Building 20.20, Room 263,  D-76128 Karlsruhe |
| mail: wilhelmi@ira.uka.de;  fax: +49 721 370455;  fon: +49 721 6084353 |
+-----------------> http://goethe.ira.uka.de/~wilhelmi <-----------------+



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]