This is the mail archive of the mailing list for the glibc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

thread local data


I am writing a user-level thread library and I would like to use TLS
(thread-local storage), that is, each user thread will have its own
copy of data declared with __thread (thread private data). I am using
the initialization image which corresponds to the ELF sections .tdata
and .tbss to create the region that holds the thread private data. In
order to context switch, I just change the gs:0x0 address to point to
the region of the next thread (assuming that the code was compiled
with -static and -mno-tls-direct-seg-refs).

There are, however, some functions in the glibc that touch data that
are local to the thread and this data is initialized before a thread
is created. For example, the function __ctype_toupper_loc uses an
array which is local to each thread. If I try to call this function
with the gs:0x0 pointing to a new created thread private data region,
this causes a reference to the 0x0 address. This is because the region
was not properly initialized. Does anyone know how to initialized the
local data used by glibc? How does the kernel thread library
initialize things like this array touched by __ctype_toupper_loc?

Thanks in advance,

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]