Threads and the LDT (Intel-specific)?
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 2 lines · Scott Long
I can also use the LDT to point to thread-specific segments. IMHO this is much better than the stack trick used by linuxthreads. The problem
Modern LinuxThreads (glibc 2.2) also uses modify_ldt for thread local data (much to the pain of the IA64 and x86-64 ports who have to emulate it..)
Quoted 2 lines
is, I don't fully understand how to use
modify_ldt(). Is anyone knowledgeable about this?
modify_ldt() works like a memcpy to/from the ldt. See the man page. On the layout of the LDT see the intel IA32 architecture manual from http://developer.intel.com
Quoted 3 lines
If anyone has any other suggestions, please let me know. If you are confused as to why I would ever want to do this in the first place, I'd be willing to go over it off the list.
I can imagine, but it'll cost you. Most modern CPUs have heavy penalties for non-zero-based or limited segments (a few cycles for every memory access) and LDT switching also makes the context switch slower.
An portable alternative is to use multiple processes with a shared memory area.
-Andi