From owner-freebsd-threads@FreeBSD.ORG Fri Jun 20 13:46:07 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 496CB37B401 for ; Fri, 20 Jun 2003 13:46:07 -0700 (PDT) Received: from mail.pcnet.com (mail.pcnet.com [204.213.232.4]) by mx1.FreeBSD.org (Postfix) with ESMTP id 741F843FA3 for ; Fri, 20 Jun 2003 13:46:06 -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 h5KKk0Xh020715; Fri, 20 Jun 2003 16:46:00 -0400 (EDT) Date: Fri, 20 Jun 2003 16:46:00 -0400 (EDT) From: Daniel Eischen X-Sender: eischen@pcnet5.pcnet.com To: Igor Sysoev In-Reply-To: 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 List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Jun 2003 20:46:07 -0000 On Fri, 20 Jun 2003, Igor Sysoev wrote: > > 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; FYI, The above has to be atomic. > gs:[0] = next_thr_tls; > kse_mailbox.km_curthread = next_kse_thr_mailbox; FYI2, The above need not be atomic since upcalls are disabled by the first line. > 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 ? We've used %gs ever since we supported multiple KSEs. Before, it was just a port of libc_r with everything global and only 1 KSE. -- Dan Eischen