Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 19 Jun 2003 15:52:24 -0700
From:      Marcel Moolenaar <marcel@xcllnt.net>
To:        Julian Elischer <julian@elischer.org>
Cc:        threads@freebsd.org
Subject:   Re: Implementing TLS: step 1
Message-ID:  <20030619225224.GC1273@dhcp01.pn.xcllnt.net>
In-Reply-To: <Pine.BSF.4.21.0306191523190.41210-100000@InterJet.elischer.org>
References:  <20030619220008.GA1273@dhcp01.pn.xcllnt.net> <Pine.BSF.4.21.0306191523190.41210-100000@InterJet.elischer.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Jun 19, 2003 at 03:36:11PM -0700, Julian Elischer wrote:
> 
> What happens when there is no thread.. (e.g. the UTS (User Thread
> Scheduler) is running and has not selected a thread to run?

The thread pointer has to point to the TLS for accesses to thread
local data. The thread pointer can point to anything if there's
no access to TLS.

For consistency you can have a sentinel structure (16-bytes), that
contains the indirection to mimic the common case. Or you can opt
to have TP (the thread pointer) point to the KSE when there's no
thread. This however can create unwanted complexity.

> Basically in libKSE there is what the kernel calls a thread, which is
> interpretted in userspace as a virtual CPU, and this is used to 
> run user level threads. The kernel sets the thread-pointer register
> upcorrectly according to which of these "kernel visible threads"
> is running. This is a legitimate use of the thread pointer register as
> far as I see.  In 1:1 (libthr) the two things are the same and it stops
> there.

It isn't on ia64. The thread pointer register has a predefined
meaning. You cannot point it to anything else than the TLS in
a process that has TLS. (if there's no TLS, the TP register is
unused (=reserved)).

See also:
	http://www.freebsd.org/platforms/ia64/refs.html

I'm not sure the runtime specification pointed to there has the
TLS info. I'll update the page ASAP if it's missing.

-- 
 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?20030619225224.GC1273>