Deadlock Recovery/Methods/Algorithms in Operating System:

We can recover from a deadlock by using two approaches:



  • Kill the processes that releases all resources for killed process.
  • Take away resources.



1. Process Termination:


When recovering from a deadlock by process termination, we have two approaches.



  • We can terminate all processes involved in a deadlock.
  • We can terminate them one by one until the deadlock disappears.



Killing all processes is costly since some processes may have been doing something important for a long time and will need to be re-executed again.


Killing one process at a time until deadlock is resolved is also costly. We must run deadlock detection algorithm every time we terminate a process to make sure we got rid of the deadlock.


Some priority must be considered when terminating processes because we do not want to kill an important process when less important processes are available. Priority might also include things like.



  • How many resources are being held by that process
  • How long has it executed
  • How long it has to go before it completes
  • How many processes will have to be terminated
  • How many resources it needs to complete its job etc.



2. Resource Preemption:


This approach takes resources from waiting processes and gives them to other processes. The victim process cannot continue regularly. We have a choice of how to handle it. We can either terminate that process or roll it back to some previous state so that it can request the resources again.


We have to consider the following factors for applying resource preemption:


Selection of the Victim:


The most important decision is the selection of the victim process to be preempted. It will be determined by considering the number of resources held by that process, the amount of time consumed by the process etc.


Rollback:


When a resource is preempted from a process, it cannot continue its normal execution. We should rollback that process to a safe state so that it can be restarted later.


Starvation:


It is possible that the same process is selected as victim process for preemption. If this happens, the process will not continue and a starvation situation will occur. We should ensure that no process should be selected as a victim more than a limited number of times.


If the system has resource preemption, a deadlock cannot occur. The type of resource preemption we are talking about is abnormal preemption. It only occurs when a deadlock detection mechanism detect a deadlock.

Leave a Reply

Subscribe to Posts | Subscribe to Comments

Blog Archive

Powered by Blogger.

- Copyright © 2013 Taqi Shah Blogspot -Metrominimalist- Powered by Blogger - Designed by Johanes Djogan -