Deadlock Prevention

Deadlock prevention can be achieved by making any one condition false from the following four conditions. Because for the deadlock these four conditions are compulsory.

1. Mutual exclusion
2. No preemptive
3. Hold and wait
4. Circular wait

Here we will seem, how to makes the conditions false ?

1. Eliminate Mutual exclusion

If all the resources are shareable then deadlock will never occur but it is not possible.

To make all resources shareable like CPU is shareable for all resources. But printer and tape drive is not shareable for all resources. So to make resources shareable like printer leads toward incorrect result. As process 1 was printing some document and P2 came for printing then we cannot start the printing of P2 at the same time.

2. Eliminate No Preemptive

In simple words make the resources preemptive to prevent deadlock situation.


If process P2 request for resource R1 and R1 is hold by Process P1 and P1 release R1 for P2 as request came then deadlock can be removed. But it is also not a good solution in all the cases like printing but might be suitable for CPU utilization.

If a resource is 90% used by a process then it preempted then it will be very Costly.

3. Eliminate Hold and wait

As new process demand for allocated resource then that allocated resource given to demanding process. For example process P1 came and it request for resource R1, R2 and R3. These resources are allocated to some other process. Then other process will release the r1, r2, r3 process at the same time for P1. It is called No hold and wait. If they don’t release then it will be hold and wait.

4. Eliminate Circular wait

If last process is demanding for first resource and that resource is allocated to first process. Loop kind situation is created there is called circular wait.

eliminate circular wait

Solution of circular wait is explained under

Process can only request for high order resource. Process cannot request for low order resource to remove circular wait.

In above diagram P3 cannot request for R1 or R2 because P3 previous request was R3 and next request will be greater than R3.

So next request for resource must be greater than previous request for resource to remove circular wait. In this way, by removing circular wait deadlock can be prevented.

Note: If we make false any one condition or more from above 4 conditions then deadlock can be prevented. Because, condition of deadlock is to fulfill above four conditions. In this way deadlock is removed.

Help Other’s By Sharing…

Contact Us

Burewala, Vehari, Punjab, Pakistan


Pin It on Pinterest