summaryrefslogtreecommitdiff
path: root/src/include/storage/proc.h
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2001-01-22 22:30:06 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2001-01-22 22:30:06 +0000
commite84c4290627c2e08f1ee9c199aa567d32b1d0fa7 (patch)
treefe8755abd291facdf1fe72aa7e6197a4b303ce40 /src/include/storage/proc.h
parent56f5f2bf82c6b5943cbb5337f8388fbb9917162d (diff)
Clean up lockmanager data structures some more, in preparation for planned
rewrite of deadlock checking. Lock holder objects are now reachable from the associated LOCK as well as from the owning PROC. This makes it practical to find all the processes holding a lock, as well as all those waiting on the lock. Also, clean up some of the grottier aspects of the SHMQueue API, and cause the waitProcs list to be stored in the intuitive direction instead of the nonintuitive one. (Bet you didn't know that the code followed the 'prev' link to get to the next waiting process, instead of the 'next' link. It doesn't do that anymore.)
Diffstat (limited to 'src/include/storage/proc.h')
-rw-r--r--src/include/storage/proc.h15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h
index 131c3397894..5fcd7c60ac7 100644
--- a/src/include/storage/proc.h
+++ b/src/include/storage/proc.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: proc.h,v 1.36 2001/01/16 20:59:34 tgl Exp $
+ * $Id: proc.h,v 1.37 2001/01/22 22:30:06 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -27,9 +27,8 @@ typedef struct
} SEMA;
/*
- * Each backend has a PROC struct in shared memory. There is also a list
- * of currently-unused PROC structs that will be reallocated to new backends
- * (a fairly pointless optimization, but it's there anyway).
+ * Each backend has a PROC struct in shared memory. There is also a list of
+ * currently-unused PROC structs that will be reallocated to new backends.
*
* links: list link for any list the PROC is in. When waiting for a lock,
* the PROC is linked into that lock's waitProcs queue. A recycled PROC
@@ -37,7 +36,7 @@ typedef struct
*/
struct proc
{
- /* proc->links MUST BE THE FIRST ELEMENT OF STRUCT (see ProcWakeup()) */
+ /* proc->links MUST BE FIRST IN STRUCT (see ProcSleep,ProcWakeup,etc) */
SHM_QUEUE links; /* list link if process is in a list */
@@ -53,7 +52,8 @@ struct proc
XLogRecPtr logRec;
- /* Info about lock the process is currently waiting for, if any */
+ /* Info about lock the process is currently waiting for, if any. */
+ /* waitLock and waitHolder are NULL if not currently waiting. */
LOCK *waitLock; /* Lock object we're sleeping on ... */
HOLDER *waitHolder; /* Per-holder info for awaited lock */
LOCKMODE waitLockMode; /* type of lock we're waiting for */
@@ -64,7 +64,7 @@ struct proc
Oid databaseId; /* OID of database this backend is using */
short sLocks[MAX_SPINS]; /* Spin lock stats */
- SHM_QUEUE holderQueue; /* list of HOLDER objects for locks held or
+ SHM_QUEUE procHolders; /* list of HOLDER objects for locks held or
* awaited by this backend */
};
@@ -138,7 +138,6 @@ extern int ProcSleep(LOCKMETHODCTL *lockctl, LOCKMODE lockmode,
LOCK *lock, HOLDER *holder);
extern PROC *ProcWakeup(PROC *proc, int errType);
extern int ProcLockWakeup(LOCKMETHOD lockmethod, LOCK *lock);
-extern void ProcAddLock(SHM_QUEUE *elem);
extern void ProcReleaseSpins(PROC *proc);
extern bool LockWaitCancel(void);
extern void HandleDeadLock(SIGNAL_ARGS);