Re: [HACKERS] Threads vs Processes

From: Kurt at DBC <kurtw(at)dbc(dot)co(dot)nz>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Merlin Moncure <merlin(dot)moncure(at)rcsonline(dot)com>, pgsql-hackers(at)postgresql(dot)org, pgsql-hackers-win32(at)postgresql(dot)org, Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, Shridhar Daithankar <shridhar_daithankar(at)persistent(dot)co(dot)in>, Claudio Natoli <claudio(dot)natoli(at)memetrics(dot)com>
Subject: Re: [HACKERS] Threads vs Processes
Date: 2003-09-26 03:52:11
Message-ID: 3F73B7EB.2000901@dbc.co.nz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-hackers-win32

Tom Lane wrote:
> I assume you mean static as in not-auto, rather than static as in
> not-global. Otherwise we have a problem here.
[...]
> Surely the addresses can be assumed constant within a thread. Otherwise
> we have a problem here too.
[...]
>>Taking addresses of TLS variables should be considered illegal,
> Sorry, no can accept that restriction.
>

I think you are okay on all 3 fronts,
from http://gcc.gnu.org/onlinedocs/gcc/Thread-Local.html#Thread-Local :

"The __thread specifier may be used alone, with the extern or static
specifiers, but with no other storage class specifier. When used with
extern or static, __thread must appear immediately after the other
storage class specifier."

and

"When the address-of operator is applied to a thread-local variable, it
is evaluated at run-time and returns the address of the current thread's
instance of that variable. An address so obtained may be used by any
thread. When a thread terminates, any pointers to thread-local variables
in that thread become invalid."

Also see "ISO/IEC 9899:1999 Edits for Thread-Local Storage" :
http://gcc.gnu.org/onlinedocs/gcc/C99-Thread-Local-Edits.html#C99%20Thread-Local%20Edits

and ELF Handling For Thread-Local Storage,
http://people.redhat.com/drepper/tls.pdf may be of interest.

Cheers,
Kurt.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2003-09-26 04:14:32 Re: Error message cleanup
Previous Message Christopher Kings-Lynne 2003-09-26 03:22:25 feature request: show pgsql version when running initdb

Browse pgsql-hackers-win32 by date

  From Date Subject
Next Message Zeugswetter Andreas SB SD 2003-09-26 08:53:14 Re: [HACKERS] Threads vs Processes
Previous Message Myron Scott 2003-09-25 23:19:21 Re: Threads vs Processes