Date: Mon, 29 Mar 2004 15:18:33 -0800 From: Peter Wemm <peter@wemm.org> To: freebsd-threads@freebsd.org Subject: Re: Thread Local Storage Message-ID: <200403291518.33559.peter@wemm.org> In-Reply-To: <Pine.GSO.4.10.10403291718320.29683-100000@pcnet5.pcnet.com> References: <Pine.GSO.4.10.10403291718320.29683-100000@pcnet5.pcnet.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Monday 29 March 2004 02:36 pm, Daniel Eischen wrote: [..] > > > > You don't need a syscall at thread switch if you do something > > > > like: > > > > > > > > _thread_switch(...) > > > > { > > > > if (tcb doesn't have LDT entry) { > > > > if (!free LDT entries) > > > > steal LDT entry from non-running thread; > > > > allocate LDT entry and point it at TLS goop for tcb. > > > > } > > > > load_gs(tcb's LDT sel); > > > > > > That's a system call on amd64. > > > > I'm not quite up to speed on amd64. So in 64-bit mode it doesn't > > really have an LDT at all, is that right? > > I'm not sure, but you have to make a system call to set it > or it's equivalent (amd64_set_fsbase()). Correct. There are two ways to do these things on this cpu. One is to use descriptor tables. The catch is that using descriptor tables forces a 4GB limit. It won't wrap around. The other way is to write to the MSRs for fsbase/gsbase. But the downside of that is that is a priviliged operation and needs to be done in supervisor mode. I don't *have* an LDT on the amd64 kernel. I'm dreading having to emulate the i386 sysarch LDT stuff already. -- Peter Wemm - peter@wemm.org; peter@FreeBSD.org; peter@yahoo-inc.com "All of this is for nothing if we don't go to the stars" - JMS/B5
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200403291518.33559.peter>