Re: [pgsql-hackers-win32] Threads vs Processes - Mailing list pgsql-hackers

From Merlin Moncure
Subject Re: [pgsql-hackers-win32] Threads vs Processes
Date
Msg-id 303E00EBDD07B943924382E153890E5434A9E2@cuthbert.rcsinc.local
Whole thread Raw
Responses Re: [pgsql-hackers-win32] Threads vs Processes
List pgsql-hackers
Tom Lane wrote:
"Merlin Moncure" <merlin.moncure@rcsonline.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



pgsql-hackers by date:

Previous
From: Sailesh Krishnamurthy
Date:
Subject: Re: PostgreSQL not ACID compliant?
Next
From: Shridhar Daithankar
Date:
Subject: Re: Threads vs Processes