Refactor shared memory allocation for semaphores
authorHeikki Linnakangas <[email protected]>
Thu, 6 Nov 2025 12:45:00 +0000 (14:45 +0200)
committerHeikki Linnakangas <[email protected]>
Thu, 6 Nov 2025 12:45:00 +0000 (14:45 +0200)
commitaa9c5fd3e3d7f1e6154474e39ab71377136d463a
treef061ab14e14dacd5f360ce892cca2a1b7038c096
parentdaf3d99d2b8bebb3361163a11ef3d232002127c9
Refactor shared memory allocation for semaphores

Before commit e25626677f, spinlocks were implemented using semaphores
on some platforms (--disable-spinlocks). That made it necessary to
initialize semaphores early, before any spinlocks could be used. Now
that we don't support --disable-spinlocks anymore, we can allocate the
shared memory needed for semaphores the same way as other shared
memory structures. Since the semaphores are used only in the PGPROC
array, move the semaphore shmem size estimation and initialization
calls to ProcGlobalShmemSize() and InitProcGlobal().

Author: Ashutosh Bapat <[email protected]>
Discussion: https://www.postgresql.org/message-id/CAExHW5seSZpPx-znjidVZNzdagGHOk06F+Ds88MpPUbxd1kTaA@mail.gmail.com
src/backend/port/posix_sema.c
src/backend/port/sysv_sema.c
src/backend/storage/ipc/ipci.c
src/backend/storage/ipc/shmem.c
src/backend/storage/lmgr/proc.c
src/include/storage/ipc.h
src/include/storage/shmem.h