From owner-freebsd-threads@FreeBSD.ORG Thu Jun 19 16:53:00 2003 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1FD9437B401 for ; Thu, 19 Jun 2003 16:53:00 -0700 (PDT) Received: from mail.pcnet.com (mail.pcnet.com [204.213.232.4]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7D19B43FB1 for ; Thu, 19 Jun 2003 16:52:59 -0700 (PDT) (envelope-from eischen@vigrid.com) Received: from mail.pcnet.com (mail.pcnet.com [204.213.232.4]) by mail.pcnet.com (8.12.8/8.12.1) with ESMTP id h5JNqtXh015244; Thu, 19 Jun 2003 19:52:55 -0400 (EDT) Date: Thu, 19 Jun 2003 19:52:55 -0400 (EDT) From: Daniel Eischen X-Sender: eischen@pcnet5.pcnet.com To: Marcel Moolenaar In-Reply-To: <20030619234158.GE1273@dhcp01.pn.xcllnt.net> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: threads@freebsd.org cc: Julian Elischer Subject: Re: Implementing TLS: step 1 X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: deischen@freebsd.org List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Jun 2003 23:53:00 -0000 On Thu, 19 Jun 2003, Marcel Moolenaar wrote: > On Thu, Jun 19, 2003 at 04:12:50PM -0700, Julian Elischer wrote: > > > > > > BTW Marcel, I think that we can get from where we are now with kse to > > what we need by just a little massaging of what points to what. > > it is possible that the register %gs could be pointed to the thread > > structure directly and we could derive the KSE from that. it will just > > make the context switches a fraction more expensive if we need to > > change the segment register.. > > Yes. On i386 because the indirection through %gs:0x0 allows having %gs > point anything we like: the KSE. On ia64 there's room for a pointer at > offset 8 in the TLS that we can use to point to whatever we like. That > context switches involve an additional pointer fiddle to make sure we > always have the indirection to the KSE is something I don't worry about. Currently, the libkse TLS pointer has to point to the KSE mailbox. It is necessary to be able to set a word in the KSE mailbox in 1 instruction. The KSE mailbox "current thread pointer" must be set to NULL to prevent upcalls. Indirecting to get to the mailbox pointer in order to set it leaves open a race condition where the TLS changes out from under us before we set it. So if TP can't point to the KSE mailbox, then there needs to be other changes in the kernel and libkse. Julian, please clarify what I've said if it doesn't seem clear. -- Dan Eischen