Skip to content

Commit 51d7e25

Browse files
committed
Improve some comments.
1 parent dd9923e commit 51d7e25

File tree

1 file changed

+25
-20
lines changed

1 file changed

+25
-20
lines changed

src/include/storage/lock.h

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/include/storage/lock.h,v 1.79 2004/07/17 03:31:26 tgl Exp $
10+
* $PostgreSQL: pgsql/src/include/storage/lock.h,v 1.80 2004/08/26 17:22:28 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -26,10 +26,10 @@ typedef struct PROC_QUEUE
2626
int size; /* number of entries in list */
2727
} PROC_QUEUE;
2828

29-
/* struct PGPROC is declared in storage/proc.h, but must forward-reference it */
29+
/* struct PGPROC is declared in proc.h, but must forward-reference it */
3030
typedef struct PGPROC PGPROC;
3131

32-
32+
/* GUC variables */
3333
extern int max_locks_per_xact;
3434

3535
#ifdef LOCK_DEBUG
@@ -41,6 +41,11 @@ extern bool Debug_deadlocks;
4141
#endif /* LOCK_DEBUG */
4242

4343

44+
/*
45+
* LOCKMODE is an integer (1..N) indicating a lock type. LOCKMASK is a bit
46+
* mask indicating a set of held or requested lock types (the bit 1<<mode
47+
* corresponds to a particular lock mode).
48+
*/
4449
typedef int LOCKMASK;
4550
typedef int LOCKMODE;
4651
/* MAX_LOCKMODES cannot be larger than the # of bits in LOCKMASK */
@@ -49,6 +54,11 @@ typedef int LOCKMODE;
4954
#define LOCKBIT_ON(lockmode) (1 << (lockmode))
5055
#define LOCKBIT_OFF(lockmode) (~(1 << (lockmode)))
5156

57+
/*
58+
* There is normally only one lock method, the default one.
59+
* If user locks are enabled, an additional lock method is present.
60+
* Lock methods are identified by LOCKMETHODID.
61+
*/
5262
typedef uint16 LOCKMETHODID;
5363
/* MAX_LOCK_METHODS is the number of distinct lock control tables allowed */
5464
#define MAX_LOCK_METHODS 3
@@ -60,18 +70,13 @@ typedef uint16 LOCKMETHODID;
6070
#define LockMethodIsValid(lockmethodid) ((lockmethodid) != INVALID_LOCKMETHOD)
6171

6272
/*
63-
* There is normally only one lock method, the default one.
64-
* If user locks are enabled, an additional lock method is present.
65-
*
66-
* This is the control structure for a lock table. It
67-
* lives in shared memory. This information is the same
68-
* for all backends.
73+
* This is the control structure for a lock table. It lives in shared
74+
* memory. Currently, none of these fields change after startup. In addition
75+
* to the LockMethodData, a lock table has a "lockHash" table holding
76+
* per-locked-object lock information, and a "proclockHash" table holding
77+
* per-lock-holder/waiter lock information.
6978
*
70-
* lockHash -- hash table holding per-locked-object lock information
71-
*
72-
* proclockHash -- hash table holding per-lock-waiter/holder lock information
73-
*
74-
* lockmethod -- the handle used by the lock table's clients to
79+
* lockmethodid -- the handle used by the lock table's clients to
7580
* refer to the type of lock table being used.
7681
*
7782
* numLockModes -- number of lock types (READ,WRITE,etc) that
@@ -81,8 +86,7 @@ typedef uint16 LOCKMETHODID;
8186
* type conflicts. conflictTab[i] is a mask with the j-th bit
8287
* turned on if lock types i and j conflict.
8388
*
84-
* masterLock -- synchronizes access to the table
85-
*
89+
* masterLock -- LWLock used to synchronize access to the table
8690
*/
8791
typedef struct LockMethodData
8892
{
@@ -156,12 +160,13 @@ typedef struct LOCK
156160

157161
/*
158162
* We may have several different transactions holding or awaiting locks
159-
* on the same lockable object. We need to store some per-waiter/holder
160-
* information for each such holder (or would-be holder).
163+
* on the same lockable object. We need to store some per-holder/waiter
164+
* information for each such holder (or would-be holder). This is kept in
165+
* a PROCLOCK struct.
161166
*
162167
* PROCLOCKTAG is the key information needed to look up a PROCLOCK item in the
163-
* proclock hashtable. A PROCLOCKTAG value uniquely identifies a lock
164-
* holder/waiter.
168+
* proclock hashtable. A PROCLOCKTAG value uniquely identifies the combination
169+
* of a lockable object and a holder/waiter for that object.
165170
*
166171
* There are two possible kinds of proclock tags: a transaction (identified
167172
* both by the PGPROC of the backend running it, and the xact's own ID) and

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy