postgreSQL 的 lightweight lock

postgreSQL 的 lightweight lock,第1张

概述LWLocks are normally used to protect not-very-long sections of computation   typedef struct LWLock { slock_t   mutex;          /* Protects LWLock and queue of PGPROCs */ bool   releaseOK;      /* T if

LWLocks are normally used to protect not-very-long sections of computation

typedef struct LWLock
{
slock_t mutex; /* Protects LWLock and queue of PGPROCs */
bool releaSEOK; /* T if ok to release waiters */
char exclusive; /* # of exclusive holders (0 or 1) */
int shared; /* # of shared holders (0..MaxBackends) */
PGPROC *head; /* head of List of waiting PGPROCs */
PGPROC *tail; /* tail of List of waiting PGPROCs */
/* tail is undefined when head is NulL */
} LWLock;

LWLock既可以封锁exclusive,又可以封锁shared,而且一个锁可以存在一个等待队列,队列中两种锁都可以有

lw lock 有一部分是固定的,在 lwlock.h 中

typedef enum LWLockID
{
BufFreeListLock,
ShmemIndexLock,
OIDGenLock,
XIDGenLock,
ProcArrayLock,
SInvalReadLock,
SInvalWriteLock,
WAlinsertLock,
WALWriteLock,
ControlfileLock,
CheckpointLock,
CLogControlLock,
SubtransControlLock,
MultixactGenLock,
MultixactOffsetControlLock,
MultixactMemberControlLock,
RelCacheInitLock,
BgWriterCommlock,
TwoPhaseStateLock,
tablespaceCreateLock,
BtreeVacuumlock,
AddinShmemInitLock,
autovacuumlock,
autovacuumScheduleLock,
SyncScanLock,
/* IndivIDual lock IDs end here */
FirstBufMapPingLock,
FirstLockMgrLock = FirstBufMapPingLock + NUM_BUFFER_PARTITIONS,

/* must be last except for MaxDynamicLWLock: */
NumFixedLWLocks = FirstLockMgrLock + NUM_LOCK_PARTITIONS,

MaxDynamicLWLock = 1000000000
} LWLockID;

余下的是可被分配的,总共有8317个,这是多个计算出来的

总结

以上是内存溢出为你收集整理的postgreSQL 的 lightweight lock全部内容,希望文章能够帮你解决postgreSQL 的 lightweight lock所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/sjk/1180293.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-06-02
下一篇2022-06-02

发表评论

登录后才能评论

评论列表(0条)

    保存