written 6.8 years ago by | modified 2.6 years ago by |
Subject: Data Structures
Topic: Synchronization
Difficulty: Medium
written 6.8 years ago by | modified 2.6 years ago by |
Subject: Data Structures
Topic: Synchronization
Difficulty: Medium
written 2.6 years ago by |
Solution:
What is Deadlock?
Necessary Conditions for Deadlock:
There are four different conditions that for Deadlock.
1) Mutual Exclusion.
2) Circular Wait.
3) Hold and Wait.
4) No preemption.
1) Mutual Exclusion:
Mutual exclusion is a resource can be held by only one process at a given time.
In this fig., if a process P1 is using some resource R at a particular instant of time, then some other process P2 can't hold or use the same resource R at that time.
2) Circular Wait:
3) Hold and Wait:
4) No preemption:
Resources cannot be removed from the processes are used to completion or released voluntarily by the process holding it.
This process P1 is using some resource R, then some other process P2 can't forcefully take that resource. so, then what's the need for various scheduling algorithm. The process P2 can request for the resource R and can wait for that resource to be freed by the process P1.