Anonymous user menu

Deadlock Prevention and Avoidance | No Mutual Exclusion Condition | Preemption Condition | No Hold and Wait | Deadlock Avoidance

Deadlock prevention ensures that deadlock is excluded from the beginning by invalidate at least one of the four necessary conditions, however deadlock prevention is often impossible to implement.


No Mutual Exclusion Condition

We have to share resources, however it is impossible for practical system. Non-blocking synchronization algorithms can avoid mutual exclusion.


Preemption Condition

When a process is holding some resources and waiting for another resources that can not be allocated to it, then this process releases all resources so other process can complete their execution. But some resources like printer, tap drivers can not be preempted.


No Hold and Wait

When a process ready to execute and requires some resources then all resources should be allocated at once that means there will not be wait for required resources. But sometime a process can be suffer from starvation and very low resource utilization.


No Circular Wait

To avoid circular wait, processes must request resources in increasing order only. But resource numbering may affects efficiency and a process may have to request a resource before it need.


Deadlock Avoidance

Deadlock avoidance algorithm ensures that a processes will never enter into unsafe or deadlock. The system requires additional apriori information regarding potential use of each resource for each process that means each process declare the maximum number of resources of each type that it may need, number of available resources, allocated resources, maximum demand of the processes. Processes inform operating system in advance that how many resources they will need.

If we allocated resources in a order such that requirement can be satisfied for each process and deadlock can not be occur then this state is called as safe state. A safe state is not a deadlocked state and not all unsafe states are deadlocked, but an unsafe state deadlock may occur.



      safe sequence is P1,P3,P0,P2,P4  so

       there is no deadlock in the  system


Deadlock Handling Methods | Deadlock Prevention and Avoidance | Deadlock Detection and Recovery | The Ostrich Approach

There are following strategies to handle deadlock in the system.


Deadlock Prevention and Avoidance

Deadlock prevention and deadlock avoidance occurs before system is deadlocked. Deadlock prevention ensure to negate at least one of the four conditions, so system will never enter a deadlock state. That means among four mutual exclusion, no prevention, hold and wait and circular wait can be avoid or deny by sharing, preemption, and increasing order resources requests.

Deadlock avoidance require careful resource allocation to avoid deadlock in the system. If the resource allocation is safe state then we allocate resources to processes otherwise deadlock can be occurred.


Deadlock Detection and Recovery

Deadlock detection and deadlock recovery occurs after system is deadlocked. We can detect deadlock using resource allocation graph (RAG). Deadlock occurs if the RAG has cycle in single instances resources type, but deadlock may be occurs if the RAG has cycle in multiple instances resources type. To check deadlock in multiple instance resources we use Banker’s algorithm.

When we terminate forcefully a process which involved in deadlock then this is known as deadlock recovery.


The Ostrich Approach

This algorithm ignore the deadlock problem.


In general, there are four strategies of dealing with deadlock problem:

1. The Ostrich Approach

Just ignore the deadlock problem altogether.

2. Deadlock Detection and Recovery

Detect deadlock and, when it occurs, take steps to recover.

3. Deadlock Avoidance

Avoid deadlock by careful resource scheduling.

4. Deadlock Prevention

Prevent deadlock by resource scheduling so as to negate at least one of the four conditions.