Rearranging kse mailbox

Julian Elischer julian at elischer.org
Fri Jul 18 16:42:04 PDT 2003



On Fri, 18 Jul 2003, Alexander Kabaev wrote:

> On Fri, 18 Jul 2003 15:15:58 -0700 (PDT)
> Julian Elischer <julian at elischer.org> wrote:
> 
> 
> > Static TLS space preceeds the location pointed to by the tp (the %gs
> > segment on x86).
> 
> I wonder how this can work for multiple threads per KSE scenario.

My mistake..

the 'tp' (thread pointer) on ia32 is defined as  %gs:0 not %gs

In other words, the thread pointer in ia32 has an extra level of
indirection. The segment referred to by %gs contains the KSE mailbox and
the first entry of that is the tp (thread pointer).

to quote the spec:
"Since the IA-32 is low on registers the thread register is encoded
indirectly through the %gs segment register.. The only requirement about
this register is that the actual thread pointer (tp) can be loaded from
the absolute address 0 via the %gs register. The following code would
load the thread poiinter in(to) the %eax register"

"  movl %gs:0 %eax "


since in libthr %gs points to an entry in an array of pointers to thread
structures, and in libkse %gs points to a kse mailbox, the first entry
of which can be a pointer to the thread structure, both libraries are
OK, and the static TLS storage would be allocated immediatly preceding
that structure (in both cases).

We could even 'fix' libc_r to set the %gs pointing to a single location
and make that location always point at the current thread..
so Even that could be made to work.


 > 
> -- 
> Alexander Kabaev
> 



More information about the freebsd-threads mailing list