Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef LWLOCK_H
00015 #define LWLOCK_H
00016
00017
00018
00019
00020
00021
00022
00023
00024 #define NUM_BUFFER_PARTITIONS 16
00025
00026
00027 #define LOG2_NUM_LOCK_PARTITIONS 4
00028 #define NUM_LOCK_PARTITIONS (1 << LOG2_NUM_LOCK_PARTITIONS)
00029
00030
00031 #define LOG2_NUM_PREDICATELOCK_PARTITIONS 4
00032 #define NUM_PREDICATELOCK_PARTITIONS (1 << LOG2_NUM_PREDICATELOCK_PARTITIONS)
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047 typedef enum LWLockId
00048 {
00049 BufFreelistLock,
00050 ShmemIndexLock,
00051 OidGenLock,
00052 XidGenLock,
00053 ProcArrayLock,
00054 SInvalReadLock,
00055 SInvalWriteLock,
00056 WALInsertLock,
00057 WALWriteLock,
00058 ControlFileLock,
00059 CheckpointLock,
00060 CLogControlLock,
00061 SubtransControlLock,
00062 MultiXactGenLock,
00063 MultiXactOffsetControlLock,
00064 MultiXactMemberControlLock,
00065 RelCacheInitLock,
00066 CheckpointerCommLock,
00067 TwoPhaseStateLock,
00068 TablespaceCreateLock,
00069 BtreeVacuumLock,
00070 AddinShmemInitLock,
00071 AutovacuumLock,
00072 AutovacuumScheduleLock,
00073 SyncScanLock,
00074 RelationMappingLock,
00075 AsyncCtlLock,
00076 AsyncQueueLock,
00077 SerializableXactHashLock,
00078 SerializableFinishedListLock,
00079 SerializablePredicateLockListLock,
00080 OldSerXidLock,
00081 SyncRepLock,
00082
00083 FirstBufMappingLock,
00084 FirstLockMgrLock = FirstBufMappingLock + NUM_BUFFER_PARTITIONS,
00085 FirstPredicateLockMgrLock = FirstLockMgrLock + NUM_LOCK_PARTITIONS,
00086
00087
00088 NumFixedLWLocks = FirstPredicateLockMgrLock + NUM_PREDICATELOCK_PARTITIONS,
00089
00090 MaxDynamicLWLock = 1000000000
00091 } LWLockId;
00092
00093
00094 typedef enum LWLockMode
00095 {
00096 LW_EXCLUSIVE,
00097 LW_SHARED,
00098 LW_WAIT_UNTIL_FREE
00099
00100
00101 } LWLockMode;
00102
00103
00104 #ifdef LOCK_DEBUG
00105 extern bool Trace_lwlocks;
00106 #endif
00107
00108 extern LWLockId LWLockAssign(void);
00109 extern void LWLockAcquire(LWLockId lockid, LWLockMode mode);
00110 extern bool LWLockConditionalAcquire(LWLockId lockid, LWLockMode mode);
00111 extern bool LWLockAcquireOrWait(LWLockId lockid, LWLockMode mode);
00112 extern void LWLockRelease(LWLockId lockid);
00113 extern void LWLockReleaseAll(void);
00114 extern bool LWLockHeldByMe(LWLockId lockid);
00115
00116 extern int NumLWLocks(void);
00117 extern Size LWLockShmemSize(void);
00118 extern void CreateLWLocks(void);
00119
00120 extern void RequestAddinLWLocks(int n);
00121
00122 #endif