This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: pthread_exit() and tss destructors


Robin Farine <robin.farine@acn-group.ch> writes:

> On Wed, 2002-02-27 at 14:05, Nick Garnett wrote:
> 
> [snip]
> 
> > 
> > It is my reading of the standard that it is the responsibility of the
> > destructor function itself to set the value to NULL, or some other
> > value. Otherwise there would be no need for {PTHREAD_DESTRUCTOR_ITERATIONS}.
> 
> The edition of POSIX 1003.1 (2001) I'm referring to mentions this in the
> description of pthread_key_create():
> 
>     "An optional destructor function may be associated with each key
>     value. At thread exit, if a key value has a non-NULL destructor
>     pointer, and the thread has a non-NULL value associated with that
>     key, the value of the key is set to NULL, and then the function
>     pointed to is called with the previously associated value as its
>     sole argument. The order of destructor calls is unspecified if more
>     than one destructor exists for a thread when it exits."

Ah, you are using the new standard specification. eCos POSIX support
was written to 1003.1-1996. The 2001 specification was unavailable at
the time we did it :-)

There's a whole pile of things we would need to do to our POSIX
implementation to bring it up to the 2001 specification. But for now
I'll put your patch into our source tree.

>     
> This seems more natural and less error prone than expecting each
> destructor to do it itself since in most of the cases, a destructor will
> run only one time. I suppose then that {PTHREAD_DESTRUCTOR_ITERATIONS}
> becomes useful when a destructor rebinds a key with a non-NULL value.
> 

I can imagine a situations where NULLing the location would be a
problem too. They have obviously changed their minds about which is
the most useful default action.


-- 
Nick Garnett, eCos Kernel Architect
Red Hat, Cambridge, UK


-- 
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]