How is thread local storage (__thread) implemented on LInux?

Posted by anon on Stack Overflow See other posts from Stack Overflow or by anon
Published on 2010-03-17T03:16:04Z Indexed on 2010/03/17 3:21 UTC
Read the original article Hit count: 267

__thread Foo foo;

How is "foo" actually resolved? Does the compiler silently replace every instance of "foo" with a function call? Is "foo" stored somewhere relative to the bottom of the stack, and the compiler stores this as "hey, for each thread, have this space near the bottom of the stack, and foo is stored as "offset x from bottom of stack"" ?

Insights please.

© Stack Overflow or respective owner

Related posts about thread-local-storage

Related posts about multi-threading