Re: Threads vs Processes - Mailing list pgsql-hackers

From Kurt at DBC
Subject Re: Threads vs Processes
Date
Msg-id 3F73B7EB.2000901@dbc.co.nz
Whole thread Raw
In response to Re: Threads vs Processes  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
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.



pgsql-hackers by date:

Previous
From: Christopher Kings-Lynne
Date:
Subject: feature request: show pgsql version when running initdb
Next
From: Tom Lane
Date:
Subject: Re: Error message cleanup