From owner-freebsd-threads@FreeBSD.ORG Tue Jun 17 09:40:59 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 4975937B401 for ; Tue, 17 Jun 2003 09:40:59 -0700 (PDT) Received: from ns1.xcllnt.net (209-128-86-226.BAYAREA.NET [209.128.86.226]) by mx1.FreeBSD.org (Postfix) with ESMTP id 29EE243FAF for ; Tue, 17 Jun 2003 09:40:58 -0700 (PDT) (envelope-from marcel@xcllnt.net) Received: from dhcp01.pn.xcllnt.net (dhcp01.pn.xcllnt.net [192.168.4.201]) by ns1.xcllnt.net (8.12.9/8.12.9) with ESMTP id h5HGevDZ055759; Tue, 17 Jun 2003 09:40:57 -0700 (PDT) (envelope-from marcel@piii.pn.xcllnt.net) Received: from dhcp01.pn.xcllnt.net (localhost [127.0.0.1]) by dhcp01.pn.xcllnt.net (8.12.9/8.12.9) with ESMTP id h5HGevst000851; Tue, 17 Jun 2003 09:40:57 -0700 (PDT) (envelope-from marcel@dhcp01.pn.xcllnt.net) Received: (from marcel@localhost) by dhcp01.pn.xcllnt.net (8.12.9/8.12.9/Submit) id h5HGerkp000850; Tue, 17 Jun 2003 09:40:53 -0700 (PDT) (envelope-from marcel) Date: Tue, 17 Jun 2003 09:40:53 -0700 From: Marcel Moolenaar To: Igor Sysoev Message-ID: <20030617164053.GD584@dhcp01.pn.xcllnt.net> References: <20030617071810.GA2451@dhcp01.pn.xcllnt.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.4i cc: threads@freebsd.org Subject: Re: Nvidia, TLS and __thread keyword -- an observation 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: Tue, 17 Jun 2003 16:40:59 -0000 On Tue, Jun 17, 2003 at 05:41:11PM +0400, Igor Sysoev wrote: > On Tue, 17 Jun 2003, Marcel Moolenaar wrote: > > > There's a definite advantage to supporting the __thread keyword in > > userland and we should add the support. It really isn't that hard, > > but it requires some thought and testing. In most cases you simply > > point your thread pointer between the control structure and the > > thread local segments. > > If the thread implementation uses gs register to point to thread > specific data: > > gs -> [ thread specific data ] > [ tls_array ] > > then this C code > > __thread int a; a = 1; > > can be translated to > > mov tls_key, %ecx > mov $gs:tls_array, %eax > mov (%eax,%ecx,4), %eax > mov $1, (%eax) The runtime specification of the platform generally dictates how TLS access sequences are to be generated. This influences how you want to implement your thread library. It's not the other way around. If our use of %gs on i386 conflicts with the runtime specification (extension), we need to change. I would also appreciate a less i386-oriented mindset on this list. What may not be a "true" standard on i386, is on ia64. -- Marcel Moolenaar USPA: A-39004 marcel@xcllnt.net