Re: Threads and the LDT (Intel-specific)?

Andi Kleen (ak@suse.de)
13 Jun 2001 11:15:53 +0200


Scott Long <smlong@teleport.com> writes:

> 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..)

> 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

> 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
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/