1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-16 15:02:33 +03:00

Split the shared-memory array of PGPROC pointers out of the sinval

communication structure, and make it its own module with its own lock.
This should reduce contention at least a little, and it definitely makes
the code seem cleaner.  Per my recent proposal.
This commit is contained in:
Tom Lane
2005-05-19 21:35:48 +00:00
parent 6910032a56
commit ee3b71f6bc
30 changed files with 923 additions and 860 deletions

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/storage/lmgr/proc.c,v 1.157 2005/04/15 04:18:10 neilc Exp $
* $PostgreSQL: pgsql/src/backend/storage/lmgr/proc.c,v 1.158 2005/05/19 21:35:46 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -49,7 +49,7 @@
#include "storage/bufmgr.h"
#include "storage/ipc.h"
#include "storage/proc.h"
#include "storage/sinval.h"
#include "storage/procarray.h"
#include "storage/spin.h"
@@ -116,8 +116,7 @@ ProcGlobalSemas(int maxBackends)
/*
* InitProcGlobal -
* initializes the global process table. We put it here so that
* the postmaster can do this initialization.
* Initialize the global process table during postmaster startup.
*
* We also create all the per-process semaphores we will need to support
* the requested number of backends. We used to allocate semaphores
@@ -263,6 +262,11 @@ InitProcess(void)
MyProc->waitProcLock = NULL;
SHMQueueInit(&(MyProc->procLocks));
/*
* Add our PGPROC to the PGPROC array in shared memory.
*/
ProcArrayAddMyself();
/*
* Arrange to clean up at backend exit.
*/
@@ -473,6 +477,9 @@ ProcKill(int code, Datum arg)
LockReleaseAll(USER_LOCKMETHOD, true);
#endif
/* Remove our PGPROC from the PGPROC array in shared memory */
ProcArrayRemoveMyself();
SpinLockAcquire(ProcStructLock);
/* Return PGPROC structure (and semaphore) to freelist */
@@ -978,12 +985,12 @@ ProcCancelWaitForSignal(void)
}
/*
* ProcSendSignal - send a signal to a backend identified by BackendId
* ProcSendSignal - send a signal to a backend identified by PID
*/
void
ProcSendSignal(BackendId procId)
ProcSendSignal(int pid)
{
PGPROC *proc = BackendIdGetProc(procId);
PGPROC *proc = BackendPidGetProc(pid);
if (proc != NULL)
PGSemaphoreUnlock(&proc->sem);