Re: LWLock/ShmemIndex startup question

Lists: pgsql-hackers
From: Claudio Natoli <claudio(dot)natoli(at)memetrics(dot)com>
To: 'Tom Lane ' <tgl(at)sss(dot)pgh(dot)pa(dot)us>, 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-13 00:11:29
Message-ID: A02DEC4D1073D611BAE8525405FCCE2B55F256@harris.memetrics.local
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

> You have broken stuff before by rearranging the sequence of
operations...

Ah, yeah, well, FWIW, if that is the only thing that gets broken in the
process of making this port, I'll be more than satisfied. Will that be held
against me forever?

> what exactly have you got in mind here?

Moving InitShmemIndex into InitShmemAllocation.

I'd like to make this the first call, inside the context of ShmemBootstrap =
true, and insert logic to avoid SpinLock acquisition/release inside
ShmemAlloc/ShmemInitStruct (when ShmemBootstrap = true). Not pretty, but
I'll trade off the removal of other ugliness (like the
ShmemLock/ShmemIndexLock spinlock memory allocation, which could then just
use ShmemAlloc).

> > ... 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.

Just working with what we've already got. There seems to be very usable code
in src/backend/port/win32/sema.c, which gets invoked as Win32 does not have
spin-locks, but unfortunately relies on ShmemInitStruct.

If you've got a shorter path in mind, I'm all ears.

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-13 04:46:40
Message-ID: 7926.1073969200@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:
>> The correct solution to that seems to lie elsewhere, ie, not use
>> semaphores for spinlocks.

> Just working with what we've already got. There seems to be very usable code
> in src/backend/port/win32/sema.c, which gets invoked as Win32 does not have
> spin-locks, but unfortunately relies on ShmemInitStruct.

Win32 certainly has spinlocks; it does not run on any hardware for which
we don't have spinlock assembler. For that matter, doesn't it have
POSIX-compatible semaphores? I'm not sure there's any need for
src/backend/port/win32/sema.c at all.

regards, tom lane