cvs commit: src/libexec/rtld-elf map_object.c rtld.c rtld.h
src/libexec/rtld-elf/amd64...
Daniel Eischen
eischen at vigrid.com
Tue Aug 3 06:47:25 PDT 2004
On Tue, 3 Aug 2004, Doug Rabson wrote:
> On Tue, 2004-08-03 at 09:51, Doug Rabson wrote:
> > dfr 2004-08-03 08:51:00 UTC
> >
> > FreeBSD src repository
> >
> > Modified files:
> > libexec/rtld-elf map_object.c rtld.c rtld.h
> > libexec/rtld-elf/alpha reloc.c rtld_machdep.h
> > libexec/rtld-elf/amd64 reloc.c rtld_machdep.h
> > libexec/rtld-elf/i386 reloc.c rtld_machdep.h
> > libexec/rtld-elf/ia64 reloc.c rtld_machdep.h
> > libexec/rtld-elf/sparc64 reloc.c rtld_machdep.h
> > Added files:
> > libexec/rtld-elf rtld_tls.h
> > Log:
> > Add support for Thread Local Storage.
>
> Thread Local Storage is a gcc feature which allows you to add a
> '__thread' modifier to the declaration of global and static variables.
> This extra modifier means that the variable's value is 'thread local',
> i.e. one thread changing its value will not affect any other thread. In
> lots of ways its similar to the per-cpu variables we use in the kernel.
>
> Most of the support is in the dynamic linker which discovers the TLS
> blocks in each shared libary and allocates memory for them. It provides
> hooks for threading libraries to allocate and initialise TLS blocks for
> each new thread and hooks which the compiler uses to resolve the address
> of a TLS variable.
>
> The main user for this right now is the OpenGL api. In OpenGL, each
> thread has a GL context object associated with it. Each call to a GL
> function implicitly references this context object. For single-threaded
> OpenGL, the context can be found by e.g. a global variable but for
> thread-safe OpenGL, the most efficient mechanism is to use TLS. This is
> how the NVidia OpenGL driver supports threading and the open source
> OpenGL drivers will use TLS in the future as well.
>
> As far as FreeBSD goes, there is nothing in the system right now that
> uses TLS. Its possible that we might use TLS for 'errno' and similar
> things in the 6.0 timeframe.
And well-designed APIs shouldn't need TLS, so don't abuse it ;-)
It is most useful for existing APIs that can't be made thread-safe
and where speed is important.
--
Dan Eischen
More information about the cvs-src
mailing list