In the previous post, we have discussed Deadlock Prevention and Avoidance. In this post, Deadlock Detection and Recovery technique to handle deadlock is discussed.
- If resources have single instance:
In this case for Deadlock detection we can run an algorithm to check for cycle in the Resource Allocation Graph. Presence of cycle in the graph is the sufficient condition for deadlock.
In the above diagram, resource 1 and resource 2 have single instances. There is a cycle R1 → P1 → R2 → P2. So, Deadlock is Confirmed.
- If there are multiple instances of resources:
Detection of the cycle is necessary but not sufficient condition for deadlock detection, in this case, the system may or may not be in deadlock varies according to different situations.
A traditional operating system such as Windows doesn’t deal with deadlock recovery as it is time and space consuming process. Real-time operating systems use Deadlock recovery.
- Recovery method
- Killing the process: killing all the process involved in the deadlock. Killing process one by one. After killing each process check for deadlock again keep repeating the process till system recover from deadlock.
- Resource Preemption: Resources are preempted from the processes involved in the deadlock, preempted resources are allocated to other processes so that there is a possibility of recovering the system from deadlock. In this case, the system goes into starvation.
- Recovery from Deadlock in Operating System
- Difference between Deadlock Prevention and Deadlock Avoidance
- Deadlock Detection Algorithm in Operating System
- Deadlock detection in Distributed systems
- Deadlock Detection in Distributed Systems
- Hierarchical Deadlock Detection in Distributed System
- Chandy-Misra-Haas's Distributed Deadlock Detection Algorithm
- Deadlock Prevention And Avoidance
- Introduction to TimeStamp and Deadlock Prevention Schemes in DBMS
- Deadlock, Starvation, and Livelock
- Difference between Deadlock and Starvation in OS
- Introduction of Deadlock in Operating System
- Operating Systems | Deadlock | Question 1
- Operating Systems | Deadlock | Question 2
- Program for Deadlock free condition in Operating System
- Conditions for Deadlock in Operating System
- Deadlock Ignorance in Operating System
- Huang's Termination detection algorithm
- Static and Dynamic Libraries | Set 1
- Peterson's Algorithm for Mutual Exclusion | Set 2 (CPU Cycles and Memory Fence)
See Quiz on Deadlock.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above
Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.
Improved By : VaibhavRai3