[M3devel] pthreads tls initialization?
Jay
jay.krell at cornell.edu
Wed Mar 18 15:33:15 CET 2009
http://www.opengroup.org/onlinepubs/000095399/functions/pthread_key_create.html
says that thread locals start as zero, but ThreadPThread.m3 does:
PROCEDURE InitHandlers () =
BEGIN
WITH r = pthread_key_create_handlers() DO END;
WITH r = pthread_setspecific_handlers(NIL) DO END;
initHandlers := FALSE;
END InitHandlers;
Any reason for that setspecific call?
I ask because I think some of this code should just be written in C.
But ideally then, the Win32 code should be too.
So I'm just reading them, and they differ oddly in that pthread keeps doing like:
if not initialized Initialize()
and Win32 allocates its thread up front locals via the Modula initializer.
Maybe pthread_key is very expensive, and avoided in single threaded apps?
But there aren't any, right, because the runtime creates threads, at least one for the garbage collector?
- Jay
More information about the M3devel
mailing list