www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Address of TLS variables

reply =?ISO-8859-1?Q?Alex_R=F8nne_Petersen?= <alex lycus.org> writes:
Hi,

Does taking the address of a TLS variable and passing it to other 
threads have defined semantics? I would assume it results in a pointer 
to the thread's instance of the TLS variable (which makes sense), but is 
passing it to other threads OK? Does the language guarantee this?

-- 
Alex Rønne Petersen
alex lycus.org
http://lycus.org
Jun 23 2012
parent Timon Gehr <timon.gehr gmx.ch> writes:
On 06/23/2012 09:51 PM, Alex Rønne Petersen wrote:
 Hi,

 Does taking the address of a TLS variable and passing it to other
 threads have defined semantics? I would assume it results in a pointer
 to the thread's instance of the TLS variable (which makes sense),
I'd assume that it results in a pointer to the original thread's TLS variable, because threads usually share the physical address space.
 but is passing it to other threads OK?
I think you could pass a T* function() thunk that takes the respective TLS variable's address instead, if that makes sense.
 Does the language guarantee this?
No, it is probably implementation/architecture dependent.
Jun 23 2012