新闻详情

新闻详情

首页 / 资讯中心 / 详情

WW-Mutex中两种算法

发布时间:2026/9/13 17:12:37来源:尧图网络
WW-Mutex中两种算法
1 Wait-DieIf the transaction holding the lock is younger, the locking transaction waits.如果持有锁的是新事务那么正在请求锁的事务就选择等待If the transaction holding the lock is older, the locking transaction backs off and dies.如果持有锁的是老事务那么正在请求锁的事务就放弃请求并终止场景: 事务A启动于10:00, 事务B启动于10:05, 事务C启动于10:10, 如果B持有锁A和C同时去获取锁,那么结果是怎样?B相对于A来说是新事务那么按规则(1), A应该等待B相对于C来说是老事务那么按规则(2), C应该放弃请求并终止linux kernelww_mutex_lock_interruptible- acquire the w/w mutex, interruptible, Lock the w/w mutex exclusively for this task.Deadlocks within a given w/w class of locks are detected and handled with thewait/die algorithm.If the lock isn’t immediately available this function will either sleep until it is (wait case).Or it selects the current context for backing off by returning -EDEADLK (die case).Trying to acquire the same lock with the same context twice is also detected and signalled by returning -EALREADY.Returns 0 if the mutex was successfully acquired.If a signal arrives while waiting for the lock then this function returns -EINTR.In the die case, the caller must release all currently held w/w mutexes for the given context and then wait for this contending lock to be available by callingww_mutex_lock_slow_interruptible.2 Wound waitIf the transaction holding the lock is younger, the locking transaction wounds the transaction holding the lock, requesting it to die.如果持有锁的是新事务(启动时间更晚的事务)那么请求锁的事务就伤害这个持锁的新事务要求它终止If the transaction holding the lock is older, it waits for the other transaction如果持有锁的是老事务(启动时间更早的事务)那么请求锁的事务就等待持有锁的老事务场景: 事务A启动于10:00, 事务B启动于10:05, 事务C启动于10:10, 如果B持有锁A和C同时去获取锁,那么结果是怎样?A先获C后获取锁的情况:B相对于A来说是新事务那么按规则(1), A应该伤害B并让B终止.此时A获得锁, 这时候如果C来获取锁那么C相对于A来说是新事务那么按规则(2), 应该等待.C先获A后获取锁的情况:B相对于C来说是老事务那么按规则(2), C应该等待; 这时候如果A来获取锁; B相对于A来说是新事务那么按规则(1), A应该伤害B并让B终止.此时A获得锁2.1 it waits for the other transaction, 其中it是指什么? other transaction又是指什么?(1) 语法层面“it” 的指代规则英文中“it” 指代前文出现过的主语而非宾语。前一句对应 Wound 场景If the transaction holding the lock is younger, the locking transaction wounds the transaction holding the lock.此处 “the locking transaction”请求锁的事务是主语后续动作 “wounds” 由它发出。后一句对应 Wait 场景If the transaction holding the lock is older, it waits for the other transaction.为了避免重复“it” 承接前一句的主语 “the locking transaction”请求锁的事务而非本句的主语 “the transaction holding the lock”持有锁的事务。(2)“other transaction” 指什么核心是 “other” 的语义 —— 指 “除了主语之外的另一个相关对象”本句的主语是 “it”即请求锁的事务句子围绕 “两个事务的锁竞争” 展开只有 “请求锁的事务” 和 “持有锁的事务” 两个主体“other transaction” 自然就是 “除了主语(持有锁的事务)之外的另一个事务”也就是 “持有锁的老事务”。
网站建设高端定制企业官网
RELATED

相关资讯

更多精彩内容,欢迎继续阅读

较早相关资讯

最新相关资讯

notebooklm-py 架构决策实录:Capability Protocol 模式从「胖联合体」到「可组合能力」的演进 2026/9/13 17:57:41

notebooklm-py 架构决策实录:Capability Protocol 模式从「胖联合体」到「可组合能力」的演进

notebooklm-py 架构决策实录:Capability Protocol 模式从「胖联合体」到「可组合能力」的演进 【免费下载链接】notebooklm-py Unofficial Python API and agentic skill for Google Gemini Notebook. Full programmatic access to NotebookLMs features—including…

阅读更多 →
如何用 screenpipe CLI 启动本地录制并验证 localhost:3030 API 可用 2026/9/13 17:57:41

如何用 screenpipe CLI 启动本地录制并验证 localhost:3030 API 可用

如何用 screenpipe CLI 启动本地录制并验证 localhost:3030 API 可用 【免费下载链接】screenpipe YC (S26) | Open Computer History | Record your screen continuously locally and provide context to your agents (Claude, Codex, Openclaw, Hermes, Runner...) 项目地址…

阅读更多 →
三步跑通首次运行:ViMax 配置管理实践指南 2026/9/13 17:57:41

三步跑通首次运行:ViMax 配置管理实践指南

三步跑通首次运行:ViMax 配置管理实践指南 【免费下载链接】ViMax "ViMax: Agentic Video Generation (Director, Screenwriter, Producer, and Video Generator All-in-One)" 项目地址: https://gitcode.com/GitHub_Trending/ai/ViMax ViMax 配置…

阅读更多 →
PDF免费去限制:5 步用 PDFPatcher 去除 PDF 复制与打印限制 2026/9/13 17:57:41

PDF免费去限制:5 步用 PDFPatcher 去除 PDF 复制与打印限制

PDF免费去限制:5 步用 PDFPatcher 去除 PDF 复制与打印限制 【免费下载链接】PDFPatcher PDF补丁丁——PDF工具箱,可以编辑书签、剪裁旋转页面、解除限制、提取或合并文档,探查文档结构,提取图片、转成图片等等 项目地址: https…

阅读更多 →
OI-wiki 十五拼图(N-Puzzle)全解:问题定义、可解性判定与 A* 启发式搜索 2026/9/13 17:57:41

OI-wiki 十五拼图(N-Puzzle)全解:问题定义、可解性判定与 A* 启发式搜索

OI-wiki 十五拼图(N-Puzzle)全解:问题定义、可解性判定与 A* 启发式搜索 【免费下载链接】OI-wiki :star2: Wiki of OI / ICPC for everyone. (某大型游戏线上攻略,内含炫酷算术魔法) 项目地址: https://…

阅读更多 →
FOC电机控制核心:SVPWM扇区判断与X、Y、Z推导实战 2026/9/13 17:54:41

FOC电机控制核心:SVPWM扇区判断与X、Y、Z推导实战

做FOC电机控制的人,最后都得过SVPWM这一关。不管你是用ST的MCSDK、TI的InstaSPIN,还是拿着论文从零写驱动,电流环输出的Vd、Vq经过反Park变换变成Vα、Vβ之后,最终都要靠SVPWM把这些“数学世界的电压”翻译成6个MOS管的开关动作。…

阅读更多 →

今日资讯

本周资讯

本月资讯

看完文章仍有疑问?

联系尧图顾问,获取一对一建站咨询

立即免费咨询 📞 400-888-8888
📞