知识卡片
循环等待制造死锁
测试先通过同步信号确认两个任务已分别持有资源,再尝试获取第二把锁,超时后核对依赖关系。业务实现可统一锁顺序或缩减持有时间。对活锁则还要观察系统持续有动作但有效工作量停滞。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- Chapter 11. Testing 死锁、活锁与超时证据 · 查看原书依据
In Figure 11-1, task one acquires lock one. Task two acquires lock two. However, neither task has given up its lock, but each tries to acquire the other lock that is already held while still keeping hold of their own. This results in a deadlock: the two tasks will never finish because they can never acquire the second lock that they are trying to acquire.
参考来源
- 位置:《Async Rust Unleashing the Power of Fearless Concurrency (Maxwell Flitton, Caroline Morton)》第11章《Chapter 11. Testing》,死锁、活锁与超时证据(来源项目 book-source,extracted/Async Rust Unleashing the Power of Fearless Concurrency (Maxwell Flitton, Caroline Morton)/_epub-src/OEBPS/ch11.html#id71)
- 结论依据:两项各持一锁并等待另一锁,形成不能自行释放的依赖环。
- 原始内容:In Figure 11-1, task one acquires lock one. Task two acquires lock two. However, neither task has given up its lock, but each tries to acquire the other lock that is already held while still keeping hold of their own. This results in a deadlock: the two tasks will never finish because they can never acquire the second lock that they are trying to acquire.