文章详情

短信预约-IT技能 免费直播动态提醒

请输入下面的图形验证码

提交验证

短信预约提醒成功

PostgreSQL 源码解读(221)- Locks(PROCLOCK Struct)

2024-04-02 19:55

关注

本节是PostgreSQL Locks中介绍PROCLOCK结构体部分,翻译自README文件.

一、PROCLOCK Struct




typedef struct PROCLOCKTAG
{
    
    LOCK       *myLock;         
    PGPROC     *myProc;         
} PROCLOCKTAG;
typedef struct PROCLOCK
{
    
    PROCLOCKTAG tag;            
    
    PGPROC     *groupLeader;    
    LOCKMASK    holdMask;       
    LOCKMASK    releaseMask;    
    SHM_QUEUE   lockLink;       
    SHM_QUEUE   procLink;       
} PROCLOCK;
#define PROCLOCK_LOCKMETHOD(proclock) \
    LOCK_LOCKMETHOD(*((proclock).tag.myLock))
---------------------------------------------------------------------------
The lock manager's PROCLOCK objects contain:
tag -
    The key fields that are used for hashing entries in the shared memory
    PROCLOCK hash table.  This is declared as a separate struct to ensure that
    we always zero out the correct number of bytes.  It is critical that any
    alignment-padding bytes the compiler might insert in the struct be zeroed
    out, else the hash computation will be random.  (Currently, we are careful
    to define struct PROCLOCKTAG so that there are no padding bytes.)
    tag.myLock
        Pointer to the shared LOCK object this PROCLOCK is for.
    tag.myProc
        Pointer to the PGPROC of backend process that owns this PROCLOCK.
    Note: it's OK to use pointers here because a PROCLOCK never outlives
    either its lock or its proc.  The tag is therefore unique for as long
    as it needs to be, even though the same tag values might mean something
    else at other times.
tag -
    与LOCK结构体中的tag字段类似,用于标识共享内存中的PROCLOCK哈希表中对应的条目.
    tag.mylock
        指向PROCLOCK所表示的共享LOCK对象的指针
    tag.myProc
        指向持有该PROCLOCK的PGPROC后台进程
holdMask -
    A bitmask for the lock modes successfully acquired by this PROCLOCK.
    This should be a subset of the LOCK object's grantMask, and also a
    subset of the PGPROC object's heldLocks mask (if the PGPROC is
    currently waiting for another lock mode on this lock).
holdMask -
    该PROCLOCK请求获得的lock模式位掩码.
    应为LOCK's grantMask掩码的子集,同时也是PGPROC's heldlocks掩码的子集.
releaseMask -
    A bitmask for the lock modes due to be released during LockReleaseAll.
    This must be a subset of the holdMask.  Note that it is modified without
    taking the partition LWLock, and therefore it is unsafe for any
    backend except the one owning the PROCLOCK to examine/change it.
releaseMask -
    在LockReleaseAll执行过程中即将被释放的lock模式位掩码.
    应为holdMask位掩码的子集.注意更新该值时不需要持有分区LWLock,因此除了自身的PROCLOCK外
    其他后台进程是不安全的.
lockLink -
    List link for shared memory queue of all the PROCLOCK objects for the
    same LOCK.
lockLink -
    共享内存中同一个LOCK的PROCLOCK对象队列链表链接.
procLink -
    List link for shared memory queue of all the PROCLOCK objects for the
    same backend.
procLink -
    共享内存中同一个后台进程所有PROCLOCK对象的的链表链接.

二、参考资料

README

免责声明:

① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。

② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341

软考中级精品资料免费领

  • 历年真题答案解析
  • 备考技巧名师总结
  • 高频考点精准押题
  • 资料下载
  • 历年真题
  • 2024年上半年信息系统项目管理师第二批次真题及答案解析(完整版)

    难度     813人已做
    查看
  • 【考后总结】2024年5月26日信息系统项目管理师第2批次考情分析

    难度     354人已做
    查看
  • 【考后总结】2024年5月25日信息系统项目管理师第1批次考情分析

    难度     318人已做
    查看
  • 2024年上半年软考高项第一、二批次真题考点汇总(完整版)

    难度     435人已做
    查看
  • 2024年上半年系统架构设计师考试综合知识真题

    难度     224人已做
    查看

相关文章

发现更多好内容

猜你喜欢

AI推送时光机
咦!没有更多了?去看看其它编程学习网 内容吧
首页课程
资料下载
问答资讯