Re: thread static

Michael Meissner <meissner@cygnus.com>
Thu, 24 Aug 1995 16:35:02 GMT

          From comp.compilers

Related articles
[4 earlier articles]
Re: thread static pardo@cs.washington.edu (1995-08-21)
Re: thread static Roger@natron.demon.co.uk (Roger Barnett) (1995-08-21)
Re: thread static pardo@cs.washington.edu (1995-08-21)
Re: thread static mfinney@inmind.com (1995-08-22)
Re: thread static erik@kroete2.freinet.de (1995-08-22)
Re: thread static mercier@cinenet.net (1995-08-24)
Re: thread static meissner@cygnus.com (Michael Meissner) (1995-08-24)
Re: thread static stefan.monnier@epfl.ch (Stefan Monnier) (1995-08-28)
Re: thread static johnr@numega.com (1995-08-28)
| List of all articles for this month |

Newsgroups: comp.compilers
From: Michael Meissner <meissner@cygnus.com>
Keywords: parallel, C
Organization: Compilers Central
References: 95-08-078 95-08-159
Date: Thu, 24 Aug 1995 16:35:02 GMT

| >Michael McNamara <mac@verilog.com, mac@giraffe.asd.sgi.com> wrote:
| >>[Dedicating a register to point to the thread hurts register allocation.]
|
| Stefan Monnier <stefan.monnier@epfl.ch> writes:
| >Registers are not *that* scarce !
|
| A huge fraction of the machines people use every day are 80x86-family
| machines, which have maybe 8 general-purpose 32-bit registers. With
| %ESP used as a stack pointer, you're down to seven; you need about two
| registers for short-lived temporaries, leaving you with five; some
| operations always place their result in a particular register,
| complicating register allocation further. Bottom line: registers can
| be scarce.


However, on a 386 or higher in 32-bit mode, you could always use one
of the segment registers FS or GS to point to thread specific data.
You need a little bit of help from the OS, but not all that much (you
need to have the OS create a desriptor in the LDT for the memory
region and size, and swap that along with the segment registers if
they are not already being preserved).


For OS threads another possibility is on a change the VM so that a
fixed region of memory (the thread static area) gets a different
mapping for each thread.


Finally, if your hardware supports atomic compare/swap or load
linked/store instructions, then you can use a global variable that is
pointer sized to hold the thread pointer and have the user space
thread handler swap it in. For OS threads, you would have to have a
system call that gives the location to swap on a per thread basis (the
old Data General operating systems AOS, AOS/VS, etc. swapped locations
16 or 16-17 for a 32-bit program on a per thread basis).


--


Post a followup to this message

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