From owner-freebsd-threads@FreeBSD.ORG Fri Jul 18 16:42:04 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 30F3437B401; Fri, 18 Jul 2003 16:42:04 -0700 (PDT) Received: from rwcrmhc12.comcast.net (rwcrmhc12.comcast.net [216.148.227.85]) by mx1.FreeBSD.org (Postfix) with ESMTP id A123643F3F; Fri, 18 Jul 2003 16:42:03 -0700 (PDT) (envelope-from julian@elischer.org) Received: from interjet.elischer.org ([12.233.125.100]) by attbi.com (rwcrmhc12) with ESMTP id <20030718234203014002gssoe>; Fri, 18 Jul 2003 23:42:03 +0000 Received: from localhost (localhost.elischer.org [127.0.0.1]) by InterJet.elischer.org (8.9.1a/8.9.1) with ESMTP id QAA16372; Fri, 18 Jul 2003 16:41:39 -0700 (PDT) Date: Fri, 18 Jul 2003 16:41:38 -0700 (PDT) From: Julian Elischer To: Alexander Kabaev In-Reply-To: <20030718181848.414318dd.ak03@gte.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: deischen@freebsd.org cc: threads@freebsd.org cc: Marcel Moolenaar Subject: Re: Rearranging kse mailbox X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Jul 2003 23:42:04 -0000 On Fri, 18 Jul 2003, Alexander Kabaev wrote: > On Fri, 18 Jul 2003 15:15:58 -0700 (PDT) > Julian Elischer wrote: > > > > Static TLS space preceeds the location pointed to by the tp (the %gs > > segment on x86). > > I wonder how this can work for multiple threads per KSE scenario. My mistake.. the 'tp' (thread pointer) on ia32 is defined as %gs:0 not %gs In other words, the thread pointer in ia32 has an extra level of indirection. The segment referred to by %gs contains the KSE mailbox and the first entry of that is the tp (thread pointer). to quote the spec: "Since the IA-32 is low on registers the thread register is encoded indirectly through the %gs segment register.. The only requirement about this register is that the actual thread pointer (tp) can be loaded from the absolute address 0 via the %gs register. The following code would load the thread poiinter in(to) the %eax register" " movl %gs:0 %eax " since in libthr %gs points to an entry in an array of pointers to thread structures, and in libkse %gs points to a kse mailbox, the first entry of which can be a pointer to the thread structure, both libraries are OK, and the static TLS storage would be allocated immediatly preceding that structure (in both cases). We could even 'fix' libc_r to set the %gs pointing to a single location and make that location always point at the current thread.. so Even that could be made to work. > > -- > Alexander Kabaev >