Re: TLS, Thread Local Storage..

From: Julian Elischer <julian_at_elischer.org>
Date: Wed, 25 Feb 2004 00:17:47 -0800 (PST)
On Tue, 24 Feb 2004, Julian Elischer wrote:

> 
> Now that the real threading libraries are in more common usage we need
> to tackle TLS. The TLS spec is NOT part of posix, but people are
> starting to write software that depends on it (e.g. nvidia)
> and that is the real definition of our requirements.
> 
> The definative doc is at:
> http://people.redhat.com/drepper/tls.pdf
> 
> We can handle the kernel  side pretty much already
> (We've had our eye on this for  a while)
> but it's the tools, linker etc that are going to be the problems..
> The library parts are "understood".
> 
> This is basically a call to find out "who is interested?"
> 
> Some people have already indicated some interest but don't let that stop 
> them from piping up again now.. 
> (people often are interested in something but time constraints
> etc. change and...)

Who can tell me how well our linker understands what gcc puts out when
given a __thread directive..

for example, 
__thread int a= 3;
extern __thread int e;
int c;
int d = 2;
void
asd(int a, int b, int c, int d, int e){}

main()
{
        int b;
        asd(a,b,c,d,e);

}

generates:
        .file   "a.c"
.globl a
        .section        .tdata,"awT",_at_progbits
        .p2align 2
        .type   a, _at_object
        .size   a, 4
a:
        .long   3
.globl d
        .data
        .p2align 2
        .type   d, _at_object
        .size   d, 4
d:
        .long   2
        .text
        .p2align 2,,3
.globl asd
        .type   asd, _at_function
asd:
        pushl   %ebp
        movl    %esp, %ebp
        leave
        ret
        .size   asd, .-asd
        .p2align 2,,3
.globl main
        .type   main, _at_function
main:
        pushl   %ebp
        movl    %esp, %ebp
        subl    $8, %esp
        andl    $-16, %esp
        movl    %gs:0, %eax
        subl    $12, %esp
        movl    e_at_INDNTPOFF, %edx
        pushl   (%edx,%eax)
        pushl   d
        pushl   c
        pushl   %ecx
        pushl   a_at_NTPOFF(%eax)
        call    asd
        addl    $32, %esp
        leave
        ret
        .size   main, .-main
        .comm   c,4,4
        .ident  "GCC: (GNU) 3.3.3 [FreeBSD] 20031106"

I don't know whether we already have all that is needed from the
linker..
I know that _at_NTPOFF is supported but without going generating
test shared libraries it's hard to see if _at_INDNTPOFF is.

The BIG question is "who knows enough about the dynamic linker to be
able to make this work for dynamic libraries..?" I gather that our
dynamic linker is not the one that linux uses and is specific to us. (Am
I wrong?) WHat is the current state of all these tools. We need to also
have code to create new tdata and tdss segments for new threads. I guess
that's up to the thread people using support code from the dynamic and
static linkers.

> 
> 
> 
> _______________________________________________
> freebsd-current_at_freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-current
> To unsubscribe, send any mail to "freebsd-current-unsubscribe_at_freebsd.org"
> 
Received on Tue Feb 24 2004 - 23:17:53 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:44 UTC