If the system is in a deadlock state, some methods for recovering it from the deadlock state must be applied.

There are various ways for recovery:

  • Allocate one resource to several processes, by violating mutual exclusion.
  • Preempt some resources from some of the deadlocked processes.
  • Abort one or more processes in order to break the deadlock.

If preemption is used:
1. Select a victim. (Which resource(s) is/are to be preempted from which process?)
2. Rollback: If we preempt a resource from a process, roll the process back to some safe state and mak it continue.

Here the OS may be probably encounter the problem of starvation. How can we guarantee that resources will not always be preempted from the same process?

In selecting a victim, important parameters are:

  • Process priorities
  • How long the process has occupied?
  • How long will it occupy to finish its job
  • How many resources of what type did the process use?
  • How many more resources does the process need to finish its job?
  • How many processes will be rolled back? (More than one victim may be selected.)

For rollback, the simplest solution is a total rollback. A better solution is to roll the victim process back only as far as it’s necessary to break the deadlock. However, the OS needs to keep more information about process states to use the second solution.

To avoid starvation, ensure that a process can be picked as a victim for only a small number of times. So, it is a wise idea to include the number of rollbacks as a parameter.

Share with : Share on Linkedin Share on Twitter Share on WhatsApp Share on Facebook