diff options
| author | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2025-11-06 14:45:00 +0200 |
|---|---|---|
| committer | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2025-11-06 14:45:00 +0200 |
| commit | aa9c5fd3e3d7f1e6154474e39ab71377136d463a (patch) | |
| tree | f061ab14e14dacd5f360ce892cca2a1b7038c096 /src/backend/port/sysv_sema.c | |
| parent | daf3d99d2b8bebb3361163a11ef3d232002127c9 (diff) | |
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
Diffstat (limited to 'src/backend/port/sysv_sema.c')
| -rw-r--r-- | src/backend/port/sysv_sema.c | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/src/backend/port/sysv_sema.c b/src/backend/port/sysv_sema.c index 6ac83ea1a82..9faaeeefc79 100644 --- a/src/backend/port/sysv_sema.c +++ b/src/backend/port/sysv_sema.c @@ -343,12 +343,8 @@ PGReserveSemaphores(int maxSemas) errmsg("could not stat data directory \"%s\": %m", DataDir))); - /* - * We must use ShmemAllocUnlocked(), since the spinlock protecting - * ShmemAlloc() won't be ready yet. - */ sharedSemas = (PGSemaphore) - ShmemAllocUnlocked(PGSemaphoreShmemSize(maxSemas)); + ShmemAlloc(PGSemaphoreShmemSize(maxSemas)); numSharedSemas = 0; maxSharedSemas = maxSemas; |
