Thread Local Storage

Daniel Eischen eischen at vigrid.com
Tue Mar 30 06:13:36 PST 2004


On Tue, 30 Mar 2004, Doug Rabson wrote:

> On Monday 29 March 2004 23:36, Daniel Eischen wrote:
> > I'd like to see libc free of TLS ;-)  The _res stuff can be
> > avoided by modifying the implementation to use thread-safe
> > APIs.  The current _res stuff can _almost_ be eliminated
> > by passing using pthread_getspecific() once and passing
> > the _res around internal APIs.  That's actually a pretty
> > simple change.
> 
> Unfortunately pthread_setspecific() and pthread_getspecific() don't work 
> for non-threaded programs whereas 'int __thread errno' works anywhere. 

It works for libc, since libc knows whether it is threaded
or not.  I think libc is always going to be sort of special,
especially since we seem to need the jump table for the
pthread_* functions to handle the static case.

I'd be in favor of not providing static thread libraries,
but there was too much opposition when I brought it up...

> It would even work for evil cases where libpthread is loaded after 
> program startup with dlopen.

-- 
Dan Eischen



More information about the freebsd-threads mailing list