内核:处理UNIX中的死锁 [英] Kernel: Dealing with deadlocks in unix

查看:100
本文介绍了内核:处理UNIX中的死锁的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果进程1锁定资源A 并等待,则

A 死锁资源B ,同时(由于右侧"位置的上下文切换),进程2锁定了资源B ,并等待对资源的访问A .

A deadlock would occur if process 1 locks resource A and waits for resource B, while simultaneously (due to context switches at the "right" places) process 2 locks resource B and waits for access to resource A.

Unix如何处理此类死锁?我在 此处 .

How does Unix deal with such deadlocks? I read the following here.

只需执行所有需要执行以下操作的进程,就可以避免许多死锁锁定多个资源,以相同的顺序锁定它们(例如,按锁名称的字母顺序)

Many deadlocks can be prevented by simply requiring all processes that lock multiple resources to lock them in the same order (e.g., alphabetically by lock name)

如何在不更改执行顺序的情况下更改获取锁的顺序?有人可以详细说明现代Unix内核采用的死锁处理方法吗?

How can it change the order in which locks are acquired without also changing the execution order? Could someone detail the approach to deadlock-handling taken by the modern Unix kernel?

推荐答案

对于Linux内核,它不处理此问题,因为它不知道如何解决它.相反,它在运行时检测到这种死锁并发出抱怨.

For Linux kernel, it does NOT handle this, because it has no idea on how to fix it. Instead, it detects this kind of deadlock at runtime and complains.

它使用的技术是lockdep,它是运行时锁定正确性验证器,有关详细信息,请查看内核文档

The technology it uses is lockdep, which is a runtime locking correctness validator, for details, please take a look at kernel document Documentation/lockdep-design.txt.

这篇关于内核:处理UNIX中的死锁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆