Skip site navigation (1) Skip section navigation (2)

Re: [HACKERS] Threads vs Processes (was: NuSphere and PostgreSQL

From: Manfred Spraul <manfred(at)colorfullife(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Claudio Natoli <claudio(dot)natoli(at)memetrics(dot)com>,Robert Treat <xzilla(at)users(dot)sourceforge(dot)net>,Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org,pgsql-hackers-win32(at)postgresql(dot)org
Subject: Re: [HACKERS] Threads vs Processes (was: NuSphere and PostgreSQL
Date: 2003-09-25 16:03:00
Message-ID: 3F7311B4.2000502@colorfullife.com (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-hackers-win32
Tom Lane wrote:

>Claudio Natoli <claudio(dot)natoli(at)memetrics(dot)com> writes:
>  
>
>>>How are you dealing with the issue of wanting some static variables to
>>>be per-thread and others not?
>>>      
>>>
>
>  
>
>>To be perfectly honest, I'm still trying to familiarize myself with the code
>>sufficiently well so that I can tell which variables need to be per-thread
>>and which are shared (and, in turn, which of these need to be protected from
>>concurrent access).
>>
No. Not protected from concurrent access. Each thread must have it's own 
copy.

>>    
>>
>
>Well, the first-order approximation would be to duplicate the current
>fork semantics: *all* static variables are per-thread, and should be
>copied from the parent thread at thread creation.  If there is some
>reasonably non-invasive way to do that, we'd have a long leg up on the
>problem.
>
There is a declspec(thread) that makes a global variable per-thread. 
AFAIK it uses linker magic to replace the actual memory accesses with 
calls to TlsAlloc() etc. Note that declspec(thread) doesn't work from 
within dynamic link libraries, but that shouldn't be a big problem.

--
    Manfred



In response to

pgsql-hackers by date

Next:From: markwDate: 2003-09-25 16:21:47
Subject: Re: More Prelimiary DBT-2 Test Results with PostgreSQL
Previous:From: Greg StarkDate: 2003-09-25 15:53:10
Subject: Re: [pgsql-www] NuSphere and PostgreSQL for windows

pgsql-hackers-win32 by date

Next:From: Keith BottnerDate: 2003-09-25 16:50:24
Subject: Re: [HACKERS] Threads vs Processes (was: NuSphere and PostgreSQL for windows)
Previous:From: Shridhar DaithankarDate: 2003-09-25 15:21:59
Subject: Re: [HACKERS] Threads vs Processes

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group