Introduction to Operating Systems: Unit II(b): Deadlock

Deadlock Recovery

Deadlock - Introduction to Operating Systems

Once deadlock has been detected in the system, the deadlock must be broken by removing one or more of the four necessary conditions.

Deadlock Recovery

• Once deadlock has been detected in the system, the deadlock must be broken by removing one or more of the four necessary conditions.

• Here one or more processes will have to be preempted, thus releasing their resources so that the other deadlocked processes can become unblocked.

1. Process termination

• Deadlock is removed by aborting a process. But aborting process is not easy. All deadlocked processes are aborted.

• Circular wait is eliminated by aborting one by one process. There will be lot of overhead. Deadlock detection algorithm must rerun after each process kill. Selection of process for aborting is difficult. Following parameters are considered : 1. Priority of the process.

2. What percentage the process finished its execution?

3. Resource used by process.

4. Need of resources to complete process remaining operation.

5. How many processes will need to be terminated?

6. Process type: Batch or interactive.

2. Resource preemption

Some times, resource  temporarily take away from its current process and allocate it to another process.

For selecting victim, following factors are considered.

1. Priority of the process. Higher priority process are usually not selected.

2. CPU time used by process. The process which is close to completion are usually not selected.

3. The number of other process that would be affected if this process were selected as the victim.

3. Recovery through rollback

• When a process in a system terminates, the system performs a rollback by undoing every operation related to the terminated process.

• Check pointing a process means that its state is written to a file so that it can be restarted later.

• Risk in this method is that the original deadlock may recover but the nondeterminancy of concurrent processing may ensure that this does not happen.

4. Starvation

Starvation is one type situation in which a process waits for an event that might never occur in the system.

Select the victim only for finite number of times. Use rollback method for selecting victim process.

Introduction to Operating Systems: Unit II(b): Deadlock : Tag: : Deadlock - Introduction to Operating Systems - Deadlock Recovery