知识卡片
一致资源顺序打断死锁环
优先避免持有一种独占资源时再申请另一种;必须多重申请时,所有代码路径遵循一致顺序,例如统一先A再B,消除相反获取顺序形成的等待环。要涵盖隐含锁和资源池,而非只修一个调用点。复杂系统难以验证全部路径时,长跑并发测试帮助重现,超时用于限制影响,不能代替顺序约束。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 构建稳定系统 · 查看原书依据
To prevent deadlocks, it is best practice to avoid acquiring one resource while holding the other. If you must do this, all code segments need to acquire the resources in the same order.
参考来源
- 位置:《Software Architecture and Decision-Making》第12章《Building Stable Systems》(来源项目:book-sources;源文件:extracted/Software Architecture and Decision-Making Leveraging Leadership, Technology, and Product Management to Build Great Products… (Srinath Perera)/_epub-src/ch12.xhtml)
- 结论依据:摘录说明优先避免持有一种独占资源时再申请另一种;必须多重申请时,所有代码路径遵循一致顺序,例如统一先A再B,消除相反获取顺序形成的等待环。其余条件结合本章相邻例子与取舍说明,数字示例不作当前性能承诺。
- 原始内容:To prevent deadlocks, it is best practice to avoid acquiring one resource while holding the other. If you must do this, all code segments need to acquire the resources in the same order.