Search your topic here

Deadlock prevention


Deadlock has following characteristics:
1) Mutual exclusion
2) Hold and wait
3) No Preemption
4) Circular wait

Deadlock prevention-
Deadlock can be prevented by eliminating any deadlock characteristics mentioned above, which are discussed below.

1) Elimination of Mutual exclusion-
Elimination of mutual exclusion is not possible, because some resources like printers, speakers are inherently not shareable.

2) Elimination of Hold and wait-
Elimination of hold and wait can be possible in the way, allocate all the necessary resources to the process before start of its execution, so there will not be any hold for the process.
But if we take the example or resources like printer, than it will get blocked to a specific process, till that process release the resource.

3) Elimination of No Preemption-
Elimination of No Preemption  can be done in the way, preempting the resource from the process when required by high priority process.

4) Elimination of Circular wait-
Elimination of circular wait can be done in the way,
Assigning a numeric identity to each process. And a process can request for the process in increasing order only.b
For example- If a process request for the resource 4, then next time it can't request for resource lesser than 4. But can for 5, 6, 7 etc.