Add comment to explain why PGReserveSemaphores() is called early
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Thu, 6 Nov 2025 10:50:10 +0000 (12:50 +0200)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Thu, 6 Nov 2025 12:20:58 +0000 (14:20 +0200)
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 <ashutosh.bapat.oss@gmail.com>
Discussion: https://www.postgresql.org/message-id/CAExHW5seSZpPx-znjidVZNzdagGHOk06F+Ds88MpPUbxd1kTaA@mail.gmail.com
Backpatch-to: 18
src/backend/storage/ipc/ipci.c

index 2fa045e6b0f66ad70a59ba715cb0e09580aee57c..8d2b0f1193d9f4308fd08e191f35568b4bbfd52d 100644 (file)
@@ -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);