2001-09-29 06:02:27 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* lwlock.h
|
|
|
|
* Lightweight lock manager
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
|
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
|
|
*
|
2001-10-25 07:50:21 +02:00
|
|
|
* $Id: lwlock.h,v 1.2 2001/10/25 05:50:10 momjian Exp $
|
2001-09-29 06:02:27 +02:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
#ifndef LWLOCK_H
|
|
|
|
#define LWLOCK_H
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We have a number of predefined LWLocks, plus a bunch of LWLocks that are
|
|
|
|
* dynamically assigned (for shared buffers). The LWLock structures live
|
|
|
|
* in shared memory (since they contain shared data) and are identified by
|
2001-10-25 07:50:21 +02:00
|
|
|
* values of this enumerated type. We abuse the notion of an enum somewhat
|
2001-09-29 06:02:27 +02:00
|
|
|
* by allowing values not listed in the enum declaration to be assigned.
|
|
|
|
* The extra value MaxDynamicLWLock is there to keep the compiler from
|
|
|
|
* deciding that the enum can be represented as char or short ...
|
|
|
|
*/
|
|
|
|
typedef enum LWLockId
|
|
|
|
{
|
2001-10-25 07:50:21 +02:00
|
|
|
BufMgrLock,
|
|
|
|
LockMgrLock,
|
|
|
|
OidGenLock,
|
|
|
|
XidGenLock,
|
|
|
|
ShmemIndexLock,
|
|
|
|
SInvalLock,
|
|
|
|
FreeSpaceLock,
|
|
|
|
MMCacheLock,
|
|
|
|
WALInsertLock,
|
|
|
|
WALWriteLock,
|
|
|
|
ControlFileLock,
|
|
|
|
CheckpointLock,
|
|
|
|
CLogControlLock,
|
2001-09-29 06:02:27 +02:00
|
|
|
|
2001-10-25 07:50:21 +02:00
|
|
|
NumFixedLWLocks,/* must be last except for
|
|
|
|
* MaxDynamicLWLock */
|
2001-09-29 06:02:27 +02:00
|
|
|
|
2001-10-25 07:50:21 +02:00
|
|
|
MaxDynamicLWLock = 1000000000
|
2001-09-29 06:02:27 +02:00
|
|
|
} LWLockId;
|
|
|
|
|
|
|
|
|
|
|
|
typedef enum LWLockMode
|
|
|
|
{
|
2001-10-25 07:50:21 +02:00
|
|
|
LW_EXCLUSIVE,
|
|
|
|
LW_SHARED
|
2001-09-29 06:02:27 +02:00
|
|
|
} LWLockMode;
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef LOCK_DEBUG
|
|
|
|
extern bool Trace_lwlocks;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
extern LWLockId LWLockAssign(void);
|
|
|
|
extern void LWLockAcquire(LWLockId lockid, LWLockMode mode);
|
|
|
|
extern bool LWLockConditionalAcquire(LWLockId lockid, LWLockMode mode);
|
|
|
|
extern void LWLockRelease(LWLockId lockid);
|
|
|
|
extern void LWLockReleaseAll(void);
|
|
|
|
|
|
|
|
extern int NumLWLocks(void);
|
|
|
|
extern int LWLockShmemSize(void);
|
|
|
|
extern void CreateLWLocks(void);
|
|
|
|
#endif /* LWLOCK_H */
|