Resource Preemption
To eliminate deadlocks using resource preemption, we preempt some resources from processes and give those resources to other processes. This method will raise three issues –
- Selecting a victim: We must determine which resources and which processes are to be preempted and also in order to minimize the cost.
- Rollback: We must determine what should be done with the process from which resources are preempted. One simple idea is total rollback. That means aborting the process and restarting it.
- Starvation: In a system, it may happen that the same process is always picked as a victim. As a result, that process will never complete its designated task. This situation is called Starvation and must be avoided. One solution is that a process must be picked as a victim only a finite number of times.
Advantages of Resource Preemption
- It can help in breaking a deadlock without terminating any processes, thus preserving data and resources.
- It is more efficient than process termination as it targets only the resources that are causing the deadlock.
- It can potentially avoid the need for restarting the system.
Disadvantages of Resource Preemption
- It may lead to increased overhead due to the need for determining which resources and processes should be preempted.
- It may cause further problems if the preempted resources were critical to the system’s operation.
- It may cause delays in the completion of processes if resources are frequently preempted.
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.