栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

数据库中的锁、共享锁、互斥锁和时间戳协议

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

数据库中的锁、共享锁、互斥锁和时间戳协议

Locks
  1. Shared Lock 共享锁/S锁

    If a transaction T has obtained a S-lock on item Q, then T can read, but cannot write Q. S-lock is requested using lock-S instruction

  2. Exclusive Lock 排他锁/X锁

    If a transaction T has obtained an X-lock on item Q, then T can both read and write Q. X-lock is requested using lock-X instruction

The Two-Phase Locking Protocol二段加锁协议

Each transaction issue lock and unlock requests in two phases:

  • Growing Phase 扩张阶段

    A transaction may obtain locks, but may not release locks

  • Shrinking Phase 收缩阶段

    A transaction may release locks, but may not obtain locks

Timestamp-based Protocols
  • Each transaction gets a timestamp when it enters the system

  • If a transaction X enters the system before Y does,

    then TS(X) < TS(Y)

  • 即:按照事务进入系统的顺序来分配时间戳,

    先进的时间戳较小,后进的时间戳较大

  • Use the value of the system clock as the timestamp

  • Use a logical counter

If TS(X) < TS(Y) , then the produced schedule is equivalent to a serial schedule in which X appears before Y

并发执行的结果,就好像事务是按照时间戳从小到大的顺序串行执行的一样

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/691543.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号