Re: Thread Local Storage
From: Casper H.S. Dik (Casper.Dik_at_Sun.COM)
Date: 31 Jan 2005 13:17:03 GMT
William Ahern <email@example.comClement.com> writes:
>Markus Gyger <firstname.lastname@example.org> wrote:
>> Gianni Mariani writes:
>> > What I'd like
>> > to see is a another section in executable files that are thread specific
>> > and a keyword when declaring a variable that would be placed in a thread
>> > specific section.
>> Sun Studio compilers on Solaris support a __thread specifier:
>> http://docs.sun.com/coll/771.6 http://docs.sun.com/coll/45.20
>As does any recent Linux/glibc/GCC environment:
>static int __thread local_index;
>/* On creation every thread gets its own local_index, initialized to 0. */
>With __thread, we've come full circle. All those non-thread safe functions
>which used static internal state are reborn. The cumbersome per-thread
>initialization is handled by the linker and the threading library, just like
>it should be. What took so long!?
Strangely enough, a feature like this existed in the initial Solaris
threads paper from early Solaris days. It was never fully implemented
(it used a #pragma ...)
-- Expressed in this posting are my opinions. They are in no way related to opinions held by my employer, Sun Microsystems. Statements on Sun products included here are not gospel and may be fiction rather than truth.