预防死锁说:
All four of the conditions are necessary for deadlock to occur, it follows that deadlock might be prevented by denying any one of the conditions.
条件
相互排斥
按住并等待
不抢占
循环等待
现在
让我们否认第一个
- Mutual Exclusion
有很多例子可以证明互斥可能会导致死锁,比如here .
现在让我们阻止这种相互排斥。但问题是
The mutual exclusion condition must hold for non-sharable resources. That is, several processes cannot simultaneously share a single resource. This condition is difficult to eliminate because some resources, such as the tape drive and printer, are inherently non-shareable.check this.
问题/疑问
我们无法消除互斥,那么**为什么它是条件之一**??
最佳答案
We cannot Elimainate Mutual Exclusion then why is it one of the condition ??
在处理不可共享资源的情况下,我们无法消除相互排斥。因此,它只是强调,对于特殊情况,当我们处理tap驱动器
和打印机
等本质上不可共享的资源时,我们必须考虑消除其他三个选项之一以防止死锁。
现在临界区并不总是意味着我们正在谈论物理资源。它也可能意味着我们正在谈论一段代码
。 变量
是本质上可共享资源的资源。所以在这种情况下我们可以消除互斥来防止死锁。但请记住,这种情况很少发生,因为如果我们在最初的设计中确保了互斥,那么它就可以确保正确的实现。因此,只是为了让您意识到可以通过防止互斥来防止死锁,但这并不意味着它实际上很普遍。
关于operating-system - 预防死锁 :Mutual Exclusion,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43261372/