Exposing gthreads, and making exceptions safe under cthreads

Tom Tromey tromey@cygnus.com
Tue Sep 22 16:05:00 GMT 1998


>>>>> "Martin" == Martin von Loewis <martin@mira.isdn.cs.tu-berlin.de> writes:

>> It seems to me that you could also implement this using a hash
>> table (or moral equivalent) in gthr-mach.h.  That is, nothing says
>> you must use the underlying thread system's mechanism for
>> thread-specific data.

Martin> Out of curiosity: How would this work?

Martin> It seems that you need *some* thread-specific state to get the
Martin> key (or whatever) to the hash table?

Yes.  You need a thread id to serve as the key for the table, and you
need a way to get the id of the currently executing thread.  If
cthreads doesn't have thread ids, then this scheme won't work.  This
seems to be a fairly common feature of thread systems, though.

Also, if you can't have some kind of cleanup run when a thread exits,
then this scheme will leak memory.

Tom



More information about the Gcc mailing list