Date: Wed, 22 Nov 2000 07:32:33 -0500 (EST) From: Daniel Eischen <eischen@vigrid.com> To: Arun Sharma <arun@sharmas.dhs.org> Cc: arch@FreeBSD.ORG Subject: Re: Thread-specific data and KSEs Message-ID: <Pine.SUN.3.91.1001122071825.3503A-100000@pcnet1.pcnet.com> In-Reply-To: <003d01c0538d$9646f260$7840a8c0@escalate.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 20 Nov 2000, Arun Sharma wrote: > Linux threads implementation uses %gs to store a pointer to > the thread structure. A segment register can only be loaded > with a selector that points to a valid entry in a LDT or a GDT > on x86. Hmm, OK. So if I initially load the LDT with entries (they don't have to point to anything unless I want to really use gs to point to something), then I can use gs. > They do the trick by using a system call to make an entry in > the LDT. In other words, the number of threads is limited by > the number of entries in the LDT :) For us, we'd be limited to the number of KSEs. I think a limit of 8188 KSEs (2^13 - 4, right?) should be more than sufficient. The number of threads could essentially be unlimited. > They still pay the cost of a privilege check each time they > load %gs. I don't really know if it is too much of a price to > pay in a thread library implementation. I don't see any other ways for i386. > Other ideas: > > Use fixed registers to store the pointer to pthread_whatever_struct > on archictures that allow it and on x86 and friends, just let the > compiler pick an unused register (you might want to use the "register" > keyword). The implementation can be hidden away in an > (architecture specific) macro. I'm not sure I follow you. The register and it's value must remain static across subprogram calls, both in the threads library and in application code. Other than the segment registers, there's not many registers available for i386 where we could afford to set one aside. > [ reference to linuxthreads ]: Thanks -- Dan Eischen To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.SUN.3.91.1001122071825.3503A-100000>