Open In App

Deadlock Prevention Policies in Distributed System

A Deadlock is a situation where a set of processes are blocked because each process is holding a resource and waiting for a resource that is held by some other process.

There are four necessary conditions for a Deadlock to happen which are: 



So the above four conditions are necessary for a deadlock to occur, if any one of the above four conditions is prevented, we can prevent a Deadlock to occur. There are 2 ways to prevent deadlock in a distributed system.

Ordered Request

As the name suggests, in this Deadlock Prevention method, each resource type is assigned a certain level to maintain a resource request policy for a process. This is known as the Resource Allocation policy. For each Resource, a global level number is assigned to impose ordering of all resource types. While requesting for a resource, a Process has to make sure that it does not request for a resource whose level order is lower than the highest-level order resource it currently holds. It can only request resources higher than the highest level resources, held by the process. Refer to the below example for a much better understanding. Suppose there are 10 resources from level 1 to 10, and 10 is the highest level order resource. If a Process currently has resources 5 and 8, it cannot request a resource below 8, it can only request resources 9 and 10. Like, the process cannot make a request for Resource 7, while holding resource 8. This method does not mean that requests should be made in increasing order of sequence. Before sending a request for resource 7, it has to release the held resource 8. After releasing 8, it can acquire 7. It is allowed because currently, it does not hold a resource higher than 7.



The Method makes sure that the Circular Wait condition is not reached and if one of the deadlock conditions is denied, the deadlock will be prevented.

Disadvantages:

Collective Request

This method prevents the Hold and Wait for condition by using any of the following Resource Allocation Policies :

Disadvantages:

Article Tags :