Deadlock prevention say :
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
Hold and Wait
No Premption
Circular Wait
Now
Let us Deny first one
- Mutual Exclusion
There are many examples to prove that Mutual Exclusion may lead to deadlock like here .
Now let us Prevent this Mutual Exclusion .But the problem is that
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 tap drive and printer, are inherently non-shareable.check this.
We cannot Elimainate Mutual Exclusion then **why is it one of the condition **??
答案 0 :(得分:3)
我们不能消除相互排斥,那为什么它是其中之一 条件??
在我们处理不可共享资源的情况下,我们无法消除互斥。因此,它只是强调,对于特殊情况,当我们处理tap drive
和printer
这些固有不可共享等资源时,我们必须考虑消除其中一个其他三个选项可以防止死锁。
现在关键部分并不总是意味着我们在谈论物理资源。这也可能意味着我们正在谈论piece of code
。 variables
是本质上可共享资源的资源。所以在这种情况下我们可以消除互斥以防止死锁。但请记住,很少这样做,因为如果我们确保在初始设计中互斥,则确保正确实施。所以只是为了让你意识到可以通过防止相互排斥来防止僵局,但这并不意味着它几乎普遍存在。