You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Before e256266 spinlocks were
implemented using semaphores on some platforms. Hence
PGReserveSemaphores() was required to be called before
SpinlockSemaInit(). SpinlockSemaInit() was required to be called before
InitShmemAllocation() since the latter initialized a spinlock to
synchronize shared memory allocations. A cyclic dependency existed
because PGReserveSemaphores() uses shared memory for semaphores on some
platforms. It was broken by letting PGReserveSemaphores() allocate
shared memory without a spinlock using ShmemAllocUnlocked(). After
e256266, spinlocks are not implemented
using semaphores at all. This allows us to eliminate the need to
estimate and allocate shared memory required by semaphores specially and
treat them similar to the other shared memory structures.
Since the semaphores are used only in PGPROC array, it makes more sense
to estimate size of memory required by semaphores to go along with the
estimation of memory required for that array in ProcGlobalShmemSize().
Similarly, it makes sense to have the actual shared memory allocations
for both to be collocated in InitProcGlobal().
With that change CalculateShmemSize() does not need to know about the
number of semaphores to be allocated, eliminating other asymmetry.
InitializeShmemGUCs() which used to get the number of semaphores through
CalculateShmemSize() now fetches that value separately.
Author: Ashutosh Bapat <[email protected]>
Discussion: https://www.postgresql.org/message-id/CAExHW5seSZpPx-znjidVZNzdagGHOk06F+Ds88MpPUbxd1kTaA@mail.gmail.com
0 commit comments