Re: [HACKERS] Threads vs Processes

From: "Merlin Moncure" <merlin(dot)moncure(at)rcsonline(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: <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 12:11:44
Message-ID: 303E00EBDD07B943924382E153890E5434A9E2@cuthbert.rcsinc.local
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-hackers-win32

Tom Lane wrote:
"Merlin Moncure" <merlin(dot)moncure(at)rcsonline(dot)com> writes:
>> All TLS variables *must* be static (or implicitly static
>> through extern, i.e. no 'auto' variables)

>I assume you mean static as in not-auto, rather than static as in
>not-global. Otherwise we have a problem here.

Yes, you are correct.

>> and their addresses can not be
>> assumed to be constant.

>Surely the addresses can be assumed constant within a thread.
Otherwise
>we have a problem here too.

Quoting from the MSDN:
The address of a thread local object is not considered constant, and any
expression involving such an address is not considered a constant
expression. In standard C, the effect of this is to forbid the use of
the address of a thread local variable as an initializer for an object
or pointer. For example, the following code will be flagged as an error
by the C compiler:
#define Thread __declspec( thread )
Thread int tls_i;
int *p = &tls_i; //This will generate an error in C.
<end>

(Note this does not apply to C++)

>> Taking addresses of TLS variables should be considered illegal,

>Sorry, no can accept that restriction.

I thought not. I believe if TLS variables are detail managed through
the win32 API, some of these problems can be avoided (after all, these
examples are for the Microsoft compiler).

Merlin

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Shridhar Daithankar 2003-09-26 12:34:11 Re: [HACKERS] Threads vs Processes
Previous Message Sailesh Krishnamurthy 2003-09-26 10:09:39 Re: PostgreSQL not ACID compliant?

Browse pgsql-hackers-win32 by date

  From Date Subject
Next Message Shridhar Daithankar 2003-09-26 12:34:11 Re: [HACKERS] Threads vs Processes
Previous Message Zeugswetter Andreas SB SD 2003-09-26 08:53:14 Re: [HACKERS] Threads vs Processes