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-25 19:48:43
Message-ID: 303E00EBDD07B943924382E153890E5434A9E0@cuthbert.rcsinc.local
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-hackers-win32

Both Microsoft and windows compilers support thread local storage. *If*
you guys go with the threading model and *if* it does not introduce any
serious portability issues with gcc (big ifs, and I'm not familiar with
gcc), than IMO TLS is really the way to go. I don't think any
reorganization of postgres's static variables is necessary. TLS is
implemented in the win32 API, not the C Libs, so by giving up the syntax
sugar you can make direct calls and keep compiler independence in win32.

Microsoft syntax is __desclspec(thread) and Borland syntax is simply
__thread. All TLS variables *must* be static (or implicitly static
through extern, i.e. no 'auto' variables) and their addresses can not be
assumed to be constant.

Taking addresses of TLS variables should be considered illegal, as well
as pointers to TLS variables. Another gotcha is that DLLs that have
__thread variables will GPF if loaded with LoadLibrary (they should be
static linked). Of course, pg does not use dlls, but it's worth noting.

Merlin

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2003-09-25 19:52:11 Re: pgsql procedures??
Previous Message Tom Lane 2003-09-25 19:41:49 pgsql-server/src/backend/executor execScan.c

Browse pgsql-hackers-win32 by date

  From Date Subject
Next Message Keith Bottner 2003-09-25 20:03:57 Re: [HACKERS] Threads vs Processes
Previous Message Keith Bottner 2003-09-25 19:16:24 Re: [HACKERS] Threads vs Processes (was: NuSphere and PostgreSQL for windows)