Deadlock Resolution



index
Disabled back button Next Section
printable version

Section 1: Overview

A deadlock occurs when we have a set of processes [not necessarily all the processes in the system], each holding some resources, each requesting some resources, and none of them is able to obtain everything that it needs to continue.

Resources can be preemptable or non-preemptable. A resource is preemptable if it can be taken away from the process that is holding it. Memory is an example of a preemptable resource.

Section 2: Conditions
Necessary For Deadlock

All of these conditions are necessary for a deadlock to occur. If any condition is not satisfied, the system is not in a deadlocked state. If it is impossible to satisfy all four conditions concurrently, deadlock is impossible.

While the four conditions must be present for a deadlock to occur, their presence does not necessarily guarantee a deadlock.

Section 3: Deadlock Prevention

The goal of deadlock prevention is to prevent the necessary conditions from being satisfied.

Deadlock prevention disallows many different ways of using resources, because they could potentially lead to deadlock.

Section 4: Deadlock Detection

Approach:

What To Do When a Deadlock Is Detected?

More details here.

Section 5: Deadlock Avoidance

Deadlock avoidance is an alternative that can yield higher resource utilization.

The goal of deadlock avoidance is to ensure that the system is always in a safe state. When in a safe state, deadlock is not possible. But if we are in an unsafe state, deadlock could occur.

To ensure that the system remains in a safe state, we must know the following for each process:

More details here.

Section 6: Resources

To learn more, google any of the approaches or read the following:

Livelocks

A condition that occurs when two or more processes continually change their state in response to changes in the other processes. The result is that none of the processes will complete.

An analogy is when two people meet in a hallway and each tries to step around the other but they end up swaying from side to side getting in each other's way as they try to get out of the way.

More details here.