Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 21 Nov 2000 16:59:57 -0800 (PST)
From:      John Baldwin <jhb@FreeBSD.org>
To:        Jake Burkholder <jburkhol@home.com>
Cc:        Daniel Eischen <eischen@vigrid.com>, arch@FreeBSD.org, Jonathan Lemon <jlemon@flugsvamp.com>
Subject:   Re: Thread-specific data and KSEs
Message-ID:  <XFMail.001121165957.jhb@FreeBSD.org>
In-Reply-To: <20001122005208.95369BA7A@io.yi.org>

next in thread | previous in thread | raw e-mail | index | archive | help

On 22-Nov-00 Jake Burkholder wrote:
>> 
>> On 21-Nov-00 Jonathan Lemon wrote:
>> > On Tue, Nov 21, 2000 at 06:51:59PM -0500, Daniel Eischen wrote:
>> >> I'm going to start working on the user-side of the new threads
>> >> library.  I need to be able to quickly get at the current KSE
>> >> (or perhaps KSEG).  Can we define a register on each architecture
>> >> that should not be used by FreeBSD ABI compliant applications?
>> >> The register doesn't have to be 32 bits or larger, just large
>> >> enough to hold the maximum number of KSEs (or KSEGs).
>> > 
>> > Um.  On a i386 I'm not sure this will be practical, there aren't 
>> > a whole lot of architecturally visible registers for use by the
>> > application.
>> 
>> Agreed.  Just use a regulare per-CPU data variable the same way that
>> 'curproc'
>> is implemented right now.
>> 
> 
> Uhh, the way curproc is implemented now is basically what he's talking
> about.  Its addressable through the %fs register, but I don't know
> how you'd set this up to work from userland.  Can you even change the
> segment registers in user mode?

Well, sort of.  I think his take would be more along the lines of storing hte
KSE number in %eax or %gs.  Actually, %gs _might_ be feasible.  Rather, having
%gs point to thread-local storage that both userland and kernel can get at
might be useful.  You can change the segment registers from user mode if you
want, but that doesn't really buy you much.

> My suggestion would be to have the stacks aligned to some power
> of 2 boundary and put your per-thread pointer at the top of the
> stack.  Then you can get at it like this:
> 
> ((stack pointer + (stack size)) & ~(stack size - 1)) - sizeof(void *)
> 
> and you don't need to know which cpu you're on.

Hmmmm....

-- 

John Baldwin <jhb@FreeBSD.org> -- http://www.FreeBSD.org/~jhb/
PGP Key: http://www.baldwin.cx/~john/pgpkey.asc
"Power Users Use the Power to Serve!"  -  http://www.FreeBSD.org/


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message




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