Re: thread static (John Robbins)
Mon, 28 Aug 1995 18:03:20 GMT

          From comp.compilers

Related articles
[6 earlier articles]
Re: thread static (1995-08-21)
Re: thread static (1995-08-22)
Re: thread static (1995-08-22)
Re: thread static (1995-08-24)
Re: thread static (Michael Meissner) (1995-08-24)
Re: thread static (Stefan Monnier) (1995-08-28)
Re: thread static (1995-08-28)
| List of all articles for this month |

Newsgroups: comp.compilers
From: (John Robbins)
Keywords: parallel, C
Organization: Compilers Central
References: 95-08-078 95-08-159
Date: Mon, 28 Aug 1995 18:03:20 GMT

>[X86 machines don't have a whole lot of registers]

>We did a nifty trick for the threads library on Solaris/x86 that used
>one of the (often unused) extra segment registers. When the thread is
>created a new ldt entry is allocated and the segment value is stored
>in %gs. While it incurs a memory reference each thread can reference its
>thread pointer via %gs:0, very convenient and it saved using a register.

>This technique could easily extend to thread specific data, simply have
>the compiler generate code for TSD via offsets from %gs and have the
>runtime system allocate an appropriately sized block when the thread
>is created...

This is exactly what is done in both Windows NT and Win95. The Thread
Environment Block is stored in the FS register and 0x2C from the
beginning of that block is the pointer to the TLS (Thread Local
Storage) Array. This is very convenient for compiler writers and, in
our case, debugger writers!


John Robbins
Nu-Mega Technologies, Inc
PO Box 7780
Nashua, NH 03060


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.