Making sense of TSD

Jason Evans jasone at
Wed Apr 11 12:05:05 PDT 2012

On Apr 11, 2012, at 10:22 AM, Mike Hommey wrote:
> I'm trying to make sense of the tsd implementation without __thread,
> which would seem to fit the tls model on windows. But I don't see why
> the wrapper struct is needed at all. The first thing that bothers me is
> that the isstatic == true case is set to abort on opt_abort, yet is
> supported. And it doesn't seem very obvious why initialized is needed.

The wrapper struct is needed with pthreads TSD because pthread_[gs]etspecific() only operate on (void *) pointers.  Thus it's impossible to store more than a pointer-sized item with pthreads TSD unless that pointer refers to an allocated structure.  I don't remember the details of Windows's TLS/TSD API; if it can store any type/structure, then no wrapper struct is needed.


More information about the jemalloc-discuss mailing list