[M3devel] pthreads tls initialization?

Jay jay.krell at cornell.edu
Thu Mar 19 02:02:11 CET 2009


But doesn't pthread_create make it so? (More so, it makes it so on any new threads.)

Or it that not portable? Or did I misunderstand the opengroup web page? Or other?

Or, is this because, like, the Modula-3 notion of "NIL" might not match the pthread notion of "NULL"? I don't believe in that extreme level of portability/disbelief/theory, but...

Unless someone can tell me about such a system.. in which

 void* p = 0; 

 printf("%p\n", p);

 memset(&p, 0, sizeof(p)); 

 printf("%p\n", q); 

 

doesn't print two identical lines.

 

I know the C standard does not guarantee this, and probably therefore Modula-3 doesn't either, but I've never heard of a system on which this isn't true.

It seems more theoretical than, say, non-IEEE floating point math (which I believe exists on VAX), or, say, 16 bit integers...

 

 - Jay

 
> From: hosking at cs.purdue.edu
> To: jay.krell at cornell.edu
> Date: Thu, 19 Mar 2009 10:22:59 +1100
> CC: m3devel at elegosoft.com
> Subject: Re: [M3devel] pthreads tls initialization?
> 
> The setspecific call is to initialize the handler stack to nil. It is 
> needed.
> 
> On 19 Mar 2009, at 01:33, Jay wrote:
> 
> >
> > 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
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20090319/53374a9d/attachment-0002.html>


More information about the M3devel mailing list