Re: LWLock/ShmemIndex startup question

Lists: pgsql-hackers
From: Claudio Natoli <claudio(dot)natoli(at)memetrics(dot)com>
To: "'pgsql-hackers(at)postgresql(dot)org'" <pgsql-hackers(at)postgresql(dot)org>
Subject: LWLock/ShmemIndex startup question
Date: 2004-01-12 09:11:29
Message-ID: A02DEC4D1073D611BAE8525405FCCE2B55F253@harris.memetrics.local
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


In CreateSharedMemoryAndSemaphores, there is the following comment, just
before CreateLWLocks():

/*
* Now initialize LWLocks, which do shared memory allocation and are
* needed for InitShmemIndex.
*/

Also, in InitShmemAllocation, there is:

/* ShmemIndex can't be set up yet (need LWLocks first) */

Are these comments still true? Specifically, is it necessary to call
CreateLWLocks before InitShmemIndex? I think it used to be, but then the
ShmemIndexLock got made into a separate spinlock in its own right.

It doesn't appear to be true, and I'd like to rearrange this section of the
code, as part of a possible solution to a Win32 shmem/semaphore bootstrap
problem (postgres semaphores under Win32 uses ShmemIndex which uses
spinlocks which use shared memory which use semaphores which ...).

If ok, I was specifically thinking of rolling the ShmemIndex initialization
into InitShmemAllocation, which I suspect used to do this anyway... any
complaints?

Cheers,
Claudio

---
Certain disclaimers and policies apply to all email sent from Memetrics.
For the full text of these disclaimers and policies see
<a
href="http://www.memetrics.com/emailpolicy.html">http://www.memetrics.com/em
ailpolicy.html</a>


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Claudio Natoli <claudio(dot)natoli(at)memetrics(dot)com>
Cc: "'pgsql-hackers(at)postgresql(dot)org'" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: LWLock/ShmemIndex startup question
Date: 2004-01-12 14:42:15
Message-ID: 28336.1073918535@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Claudio Natoli <claudio(dot)natoli(at)memetrics(dot)com> writes:
> Are these comments still true? Specifically, is it necessary to call
> CreateLWLocks before InitShmemIndex? I think it used to be, but then the
> ShmemIndexLock got made into a separate spinlock in its own right.

I think the only dependency was that ShmemIndexLock was an LWLock.

> It doesn't appear to be true, and I'd like to rearrange this section of the
> code,

You have broken stuff before by rearranging the sequence of
operations... what exactly have you got in mind here?

> ... a possible solution to a Win32 shmem/semaphore bootstrap
> problem (postgres semaphores under Win32 uses ShmemIndex which uses
> spinlocks which use shared memory which use semaphores which ...).

The correct solution to that seems to lie elsewhere, ie, not use
semaphores for spinlocks.

regards, tom lane