Claudio Natoli <claudio.natoli@memetrics.com> writes:
> FWIW, I've done a code walk-through, and it looks ok (lack of real-world
> testing notwithstanding), and actually does use the Win32 sema set. The only
> real problem is that it calls ShmemInitStruct in semget, which ultimately
> gets us into bootstrap hell (without native spinlocks, at least).
Right. The advantage of the pg_sema.h API is that you don't need any
shared control data. Take a close look at the way posix_sema works:
the management information needed to release the semas at shutdown is
private to the postmaster. What is in shared memory need only be a
reference or token (whatever you have to hand to the lock/unlock calls).
Also, allocation of the shmem space is not the responsibility of the
startup routine. So all these issues go away as long as you're not
trying to emulate the SysV interface.
regards, tom lane