Deeadlock prevention :Mutual Exclusion

时间:2017-04-06 16:53:07

标签: operating-system synchronization deadlock

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.

condition

  1. Mutual Exclusion

  2. Hold and Wait

  3. No Premption

  4. Circular Wait

Now

Let us Deny first one

  1. 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.

Question/Doubt

We cannot Elimainate Mutual Exclusion then **why is it one of the condition **??

1 个答案:

答案 0 :(得分:3)

  

我们不能消除相互排斥,那为什么它是其中之一   条件??

在我们处理不可共享资源的情况下,我们无法消除互斥。因此,它只是强调,对于特殊情况,当我们处理tap driveprinter这些固有不可共享等资源时,我们必须考虑消除其中一个其他三个选项可以防止死锁。

现在关键部分并不总是意味着我们在谈论物理资源。这也可能意味着我们正在谈论piece of codevariables是本质上可共享资源的资源。所以在这种情况下我们可以消除互斥以防止死锁。但请记住,很少这样做,因为如果我们确保在初始设计中互斥,则确保正确实施。所以只是为了让你意识到可以通过防止相互排斥来防止僵局,但这并不意味着它几乎普遍存在。