Deadlock recovery is the process of resolving a deadlock once it has occurred, allowing the system to continue functioning.
- This involves breaking the deadlock by releasing resources or terminating processes involved in the deadlock.
Some common recovery methods are:
For Resources:
1.) Preempt the Resource
- Forcefully take a resource away from a process and reassign it to another process to break the condition of deadlock. However, it is only viable for resources that can be temporarily reassigned without causing issues.
2.) Rollback to a Safe State
- Rollback involves taking a deadlocked process back to a previous safe state where it did not hold any resources. This requires keeping track of the process’s state history.
- To facilitate rollback, systems often use checkpointing, where they save the state of a process periodically.
For Process:
1.) Kill a Process
- Terminate one of the processes involved in the deadlock to free up resources and break the cycle. The process with the least cost or impact on the system is typically chosen.
2.) Kill All Processes
- Terminate all processes involved in the deadlock to ensure that all resources are released, breaking the deadlock completely.
- It is applied when it’s difficult to determine which process to terminate or when recovery must be immediate.