Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 17 Jun 2003 09:40:53 -0700
From:      Marcel Moolenaar <marcel@xcllnt.net>
To:        Igor Sysoev <is@rambler-co.ru>
Cc:        threads@freebsd.org
Subject:   Re: Nvidia, TLS and __thread keyword -- an observation
Message-ID:  <20030617164053.GD584@dhcp01.pn.xcllnt.net>
In-Reply-To: <Pine.BSF.4.21.0306171714110.326-100000@is>
References:  <20030617071810.GA2451@dhcp01.pn.xcllnt.net> <Pine.BSF.4.21.0306171714110.326-100000@is>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030617164053.GD584>