Deadlock Detection And Recovery (original) (raw)

Last Updated : 15 Apr, 2026

Deadlock detection and recovery is the mechanism of detecting and resolving deadlocks in an operating system. In operating systems, deadlock recovery is important to keep everything running smoothly. A deadlock occurs when two or more processes are blocked, waiting for each other to release the resources they need.

Approaches to Deadlock Detection and Recovery

Prevention vs. Detection/Recovery

Read more about - Deadlock Prevention and Avoidance

**Deadlock Detection

Deadlock detection is a mechanism in operating systems used to identify whether a set of processes is stuck in a deadlock state. It analyzes resource allocation and process dependencies to detect cycles and determine if processes are waiting indefinitely for resources.

**1. If Resources Have a Single Instance

In this case for Deadlock detection, we can run an algorithm to check for the cycle in the Resource Allocation Graph. The presence of a cycle in the graph is a sufficient condition for deadlock.

In the below diagram, resource 1 and resource 2 have single instances. There is a cycle R1 → P1 → R2 → P2. So, Deadlock is Confirmed.

frame_3197.webp

**2. If There are Multiple Instances of Resources

Detection of the cycle is necessary but not a sufficient condition for deadlock detection, in this case, the system may or may not be in deadlock varies according to different situations.

For systems with multiple instances of resources, algorithms like Banker's Algorithm can be adapted to periodically check for deadlocks.

**3. Wait-For Graph Algorithm

The Wait-For Graph Algorithm is a deadlock detection algorithm used to detect deadlocks in a system where resources can have multiple instances. The algorithm works by constructing a Wait-For Graph, which is a directed graph that represents the dependencies between processes and resources.

d.webp

Deadlock Recovery

A traditional operating system such as Windows doesn't deal with deadlock recovery as it is a time and space-consuming process. Real-time operating systems use Deadlock recovery.

frame_35

Kind of Recovery

Advantages of Deadlock Detection and Recovery

Disadvantages of Deadlock Detection and Recovery