Refactor shared memory allocation for semaphores
Heikki Linnakangas <heikki.linnakangas@iki.fi>
Author:
Heikki Linnakangas <heikki.linnakangas@iki.fi>
Date: 2025-11-06T12:45:00Z
Releases:
19 (unreleased)
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 <ashutosh.bapat.oss@gmail.com> Discussion: https://www.postgresql.org/message-id/CAExHW5seSZpPx-znjidVZNzdagGHOk06F+Ds88MpPUbxd1kTaA@mail.gmail.com
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/port/posix_sema.c | modified | +1 −5 |
| src/backend/port/sysv_sema.c | modified | +1 −5 |
| src/backend/storage/ipc/ipci.c | modified | +5 −26 |
| src/backend/storage/ipc/shmem.c | modified | +2 −1 |
| src/backend/storage/lmgr/proc.c | modified | +4 −0 |
| src/include/storage/ipc.h | modified | +1 −1 |
| src/include/storage/shmem.h | modified | +0 −1 |
Discussion
- Calling PGReserveSemaphores() from CreateOrAttachShmemStructs 8 messages · 2025-08-25 → 2025-11-07