From owner-freebsd-threads@FreeBSD.ORG Fri Jun 20 11:27:14 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 D721337B401 for ; Fri, 20 Jun 2003 11:27:14 -0700 (PDT) Received: from park.rambler.ru (park.rambler.ru [81.19.64.101]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6B67B43FBF for ; Fri, 20 Jun 2003 11:27:13 -0700 (PDT) (envelope-from is@rambler-co.ru) Received: from is.park.rambler.ru (is.park.rambler.ru [81.19.64.102]) by park.rambler.ru (8.12.6/8.12.6) with ESMTP id h5KIR8mF052312; Fri, 20 Jun 2003 22:27:08 +0400 (MSD) Date: Fri, 20 Jun 2003 22:27:08 +0400 (MSD) From: Igor Sysoev X-Sender: is@is To: Julian Elischer In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: threads@freebsd.org Subject: Re: Implementing TLS: step 1 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, 20 Jun 2003 18:27:15 -0000 On Fri, 20 Jun 2003, Julian Elischer wrote: > On Fri, 20 Jun 2003, Igor Sysoev wrote: > > > If we could sacrifice our current thread compatibility in 5.0-5.1 > > then we could change kse_mailbox from > > > > struct kse_mailbox { > > int km_version; /* Mailbox version */ > > struct kse_thr_mailbox *km_curthread; /* Current thread */ > > ... > > > > to > > > > struct kse_mailbox { > > struct kse_thr_mailbox *km_curthread; /* Current thread */ > > int km_version; /* Mailbox version */ > > ... > > > > then x86's gs would still point to kse_mailbox, and gs:[0] would be > > and TP pointer. Also we need to modify > > > > struct kse_thr_mailbox { > > + void *tls; > > ucontext_t tm_context; /* User thread context */ > > ... > > > > And the static TLS must be allocated before kse_thr_mailbox. > > Yes. > This is what I was thinking... I'm wrong, this scheme does not allow to use the 1:1 model in libkse when kse_mailbox.km_curthread is always NULL. We can implement such scheme on x86: gs -> [ TP ] ---> [ TLS ] [ struct kse_mailbox ] +-> [ struct kse_thr_mailbox ] [ .km_curthread ] -+ When UTS would switch to the next thread it should set thread's TLS: kse_mailbox.km_curthread = NULL; gs:[0] = next_thr_tls; kse_mailbox.km_curthread = next_kse_thr_mailbox; kse_mailbox can be accessed via gs register. On amd64 scheme is the same except the use of fs register instead of gs. However on sparc64, ia64 and alpha TP is in the register but not in the memory so we need introduce the new field tm_kse in kse_thr_mailbox to find kse_mailbox: TP -> [ TLS ] [ struct kse_thr_mailbox ] [ .tm_kse ] ---> [ struct kse_mailbox ] By the way how was kse_mailbox being found before gs register was used ? Igor Sysoev http://sysoev.ru/en/