Skip site navigation (1)Skip section navigation (2)
Date:      30 Mar 2004 15:40:46 +0100
From:      Doug Rabson <dfr@nlsystems.com>
To:        Daniel Eischen <eischen@vigrid.com>
Cc:        freebsd-threads@freebsd.org
Subject:   Re: Thread Local Storage
Message-ID:  <1080657646.18663.9.camel@builder02.qubesoft.com>
In-Reply-To: <Pine.GSO.4.10.10403300906270.11014-100000@pcnet5.pcnet.com>
References:  <Pine.GSO.4.10.10403300906270.11014-100000@pcnet5.pcnet.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 2004-03-30 at 15:13, Daniel Eischen wrote:
> 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.

Right now, the stubs for setspecific and getspecific are too simplistic
which means that libc can't use them for anything interesting. The nice
part of using TLS for errno is that libc doesn't have to care whether or
not its threaded (in this tiny area, anyway). It even makes it
straightforward to preserve the value of errno (or any other
thread-specific value) when a threading library is loaded.

Anyway, this is all blue-sky stuff which isn't relavent to the matter in
hand. I was just getting into the whole TLS thing, which is kind of neat
(IMHO) :-)

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

Bah. Static sucks. The only way I can see to make TLS work for static is
to implement it in the kernel and setup %gs in setregs :-(.




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1080657646.18663.9.camel>