Strategies for Handling Deadlock
Strategies for Handling Deadlock
The Strategies for handling Deadlock are:
- Deadlock Ignorance
- Deadlock Prevention
- Deadlock Avoidance
- Deadlock Detection and Recovery
Deadlock Ignorance
Deadlock Ignorance is the most popular deadlock handling strategy. We can use this in the various operating systems for end-users uses. In the deadlock ignorance mechanism, the OS assumes that Deadlock will not happen and ignores the Deadlock.
Deadlock ignorance is one of the suitable mechanisms for a single end-user system in which the user uses the resources for browsing and some ordinary stuff.
Always there is a tradeoff between performance and correctness. The Linux and Windows operating systems are more focused on the performance. Although, if all the time we use the deadlock handling mechanism, then due to this, the system performance decreases. When Deadlock occurs 1 out of 100 times, then the use of the deadlock handling mechanism is irrelevant.
In this, the user only needs to restart the computer in the situation of Deadlock, and mostly we use this approach in Linux and Windows operating system.
Deadlock Prevention
Every time Deadlock occurs at the time when the four conditions happen concurrently, and the four conditions are Mutual Exclusion, Hold and Wait, No Preemption, and Circular Wait. If there is a possibility of interrupting one of the conditions among the four conditions, then we can stop the occurrence of Deadlock in the system.
There is a simple reason behind this mechanism. That is, we only have to fail in any one of the conditions.
Deadlock Avoidance
Another approach used for handling a deadlock is deadlock avoidance. In this approach, the OS verifies or examines the system state means it checks that system is in a safe state or unsafe state at each step. And this process continues until the system is in the safe system. If the system comes into an unsafe state, then, in this case, the operating system will backtrack one step.
In other words, the operating system verifies every allocation so that the Deadlock may not occur in the system.
Deadlock Detection and Recovery
In Deadlock Detection and Recovery, we regularly check that Deadlock has occurred or not in the system. And if there is a deadlock in the system, then we apply some methods to remove Deadlock in the system.