From: Heikki Linnakangas Date: Thu, 6 Nov 2025 10:50:10 +0000 (+0200) Subject: Add comment to explain why PGReserveSemaphores() is called early X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=daf3d99d2b8bebb3361163a11ef3d232002127c9;p=users%2Frhaas%2Fpostgres.git 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 --- diff --git a/src/backend/storage/ipc/ipci.c b/src/backend/storage/ipc/ipci.c index 10ffce8d17..19f9c77448 100644 --- a/src/backend/storage/ipc/ipci.c +++ b/src/backend/storage/ipc/ipci.c @@ -227,7 +227,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);