Approaches To Breaking a Deadlock
Process Termination
To eliminate the deadlock, we can simply kill one or more processes. For this, we use two methods:
- Abort all the Deadlocked Processes: Aborting all the processes will certainly break the deadlock but at a great expense. The deadlocked processes may have been computed for a long time, and the result of those partial computations must be discarded and there is a probability of recalculating them later.
- Abort one process at a time until the deadlock is eliminated: Abort one deadlocked process at a time, until the deadlock cycle is eliminated from the system. Due to this method, there may be considerable overhead, because, after aborting each process, we have to run a deadlock detection algorithm to check whether any processes are still deadlocked.
Advantages of Process Termination
- It is a simple method for breaking a deadlock.
- It ensures that the deadlock will be resolved quickly, as all processes involved in the deadlock are terminated simultaneously.
- It frees up resources that were being used by the deadlocked processes, making those resources available for other processes.
Disadvantages of Process Termination
- It can result in the loss of data and other resources that were being used by the terminated processes.
- It may cause further problems in the system if the terminated processes were critical to the system’s operation.
- It may result in a waste of resources, as the terminated processes may have already completed a significant amount of work before being terminated.
Recovery from Deadlock in Operating System
In today’s world of computer systems and multitasking environments, deadlock is an undesirable situation that can bring operations to a grinding halt. When multiple processes compete for exclusive access to resources and end up in a circular waiting pattern, a deadlock occurs. To maintain the smooth functioning of an operating system, it is crucial to implement recovery mechanisms that can break these deadlocks and restore the system’s productivity.
“Recovery from Deadlock in Operating Systems” refers to the set of techniques and algorithms designed to detect, resolve, or mitigate deadlock situations. These methods ensure that the system can continue processing tasks efficiently without being trapped in an eternal standstill. Let’s take a closer look at some of the key strategies employed.
There is no mechanism implemented by the OS to avoid or prevent deadlocks. The system, therefore, assumes that a deadlock will undoubtedly occur. The OS periodically checks the system for any deadlocks in an effort to break them. The OS will use various recovery techniques to restore the system if it encounters any deadlocks.
When a Deadlock Detection Algorithm determines that a deadlock has occurred in the system, the system must recover from that deadlock.