From 75ec47c38bcf8777164cf91885eb907eb3fc369b Mon Sep 17 00:00:00 2001 From: Heikki Linnakangas Date: Thu, 6 Nov 2025 12:50:10 +0200 Subject: [PATCH] Add comment to explain why PGReserveSemaphores() is called early Before commit e25626677f, PGReserveSemaphores() had to be called before SpinlockSemaInit() because spinlocks were implemented using semaphores on some platforms (--disable-spinlocks). Add a comment explaining that. Author: Ashutosh Bapat Discussion: https://www.postgresql.org/message-id/CAExHW5seSZpPx-znjidVZNzdagGHOk06F+Ds88MpPUbxd1kTaA@mail.gmail.com Backpatch-to: 18 --- src/backend/storage/ipc/ipci.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/backend/storage/ipc/ipci.c b/src/backend/storage/ipc/ipci.c index 2fa045e6b0f..8d2b0f1193d 100644 --- a/src/backend/storage/ipc/ipci.c +++ b/src/backend/storage/ipc/ipci.c @@ -225,7 +225,9 @@ CreateSharedMemoryAndSemaphores(void) InitShmemAccess(seghdr); /* - * Create semaphores + * Create semaphores. (This is done here for historical reasons. We used + * to support emulating spinlocks with semaphores, which required + * initializing semaphores early.) */ PGReserveSemaphores(numSemas); -- 2.47.3