support for __thread

Daniel Eischen eischen at vigrid.com
Sun Dec 21 14:31:07 PST 2003


On Sun, 21 Dec 2003, Alfred Perlstein wrote:

> * Daniel Eischen <eischen at vigrid.com> [031221 12:08] wrote:
> > On Sun, 21 Dec 2003, Alfred Perlstein wrote:
> > 
> > > * Alfred Perlstein <bright at mu.org> [031221 02:47] wrote:
> > > > How do I get __thread to work for me?
> > > > 
> > > > http://gcc.gnu.org/onlinedocs/gcc/Thread-Local.html
> > > > 
> > > > it seems the assembler chokes on it?
> > 
> > We don't have support for it yet.  Why do you want it?
> 
> .) it'd be nice to have it for future work
> .) linux seems to have it, so does MS

libkse is ready to add support for it but I believe there's
some additional work to be done in rtld-elf first.

> but mostly:
> 
> I'm porting webstone to use threads, and it uses that construct
> for the win32 threaded portion, it'd be really nice if we supported
> it so that I could make use of it instead of changing hundreds of
> lines of code.

I would discourage using __thread and instead make the API
better so it's not needed.  My fear is that once we have it,
it'll be abused in all sorts of ways.  I can understand
needing it for something like nvidia's OpenGL where you
have an existing API layered over their drivers and they
need to get thread-local-storage very often (tight loops).

> Any idea of how much effort it would take?  I have no clue as to
> how to fix our toolchain, gooing the work in ld.so doesn't see
> that awful, but it's not trivial either:
> 
> http://people.freebsd.org/~alfred/tls.pdf

Yes, we've been over that in either -current or -threads; I forget
which.  I think libkse already obeys the tls spec WRT %gs; we just need
some hooks/coordination into/with rtld.

> I want a threaded webstone so that I can generate a lot more load
> with wimpier client boxes on FreeBSD.
>
> Right now doing hundreds of connections nearly kills my desktop,
> but when threaded it barely hiccups.

There is always pthread_[gs]pecific which is what normally should
be used.
 
> Also, in re: thread things:
>  http://www.freebsd.org/cgi/query-pr.cgi?pr=bin/60477
> :(

There were some thoughts on restructuring our name lookups so
that they would be thread-safe.  I would rather see that than
littering __thread around libc.

-- 
Dan Eischen



More information about the freebsd-hackers mailing list