Deadlock Detection and Recovery

In deadlock detection and recovery, to avoid or prevent a deadlock, the operating system uses various methods. For checking deadlock, an operating system continuously monitors the system. Then also, if a deadlock occurs in the system, it applies the techniques to remove the deadlock.

In deadlock detection and recovery, the major task performed by the operating system is to detect the deadlock. By using a resource allocation graph, the operating system can easily detect the deadlock.

In single instance resource type, to detect deadlock in the system, we check whether any cycle is formed in the system or not. If there is a cycle created in the system, then it means deadlock has occurred in the system, and if there is no cycle, then the system is free from deadlock.

In multiple instance, resource types also, we check the cycle is formed or not in the system, but that’s not enough to detect the deadlock. We also need to use some safety algorithm on the system so that we can convert the resource allocation graph into the request and the allocation matrix.

In an operating system, to recover deadlock, the operating system examines either resources or processes.

For Resources

Preempt the Resource: – In this, we take the resource from one process to the process that needs it to finish its execution, and after the execution is completed, the process soon releases the resource. In this, the resource selection is difficult, and the snatching of the resource is also difficult.

Rollback to a safe State: – To enter into the deadlock, the system goes through several states. In this, the operating system can easily roll back the system to the earlier safe state. To do so, we require to implement checkpoints at every state. At the time when we detect deadlock, then we need to rollback every allocation so that we can enter into the earlier safe state.

For Process                                   

Kill a Process: – In this, we kill the process due to which deadlock occurred. But the selection of the process to kill is a tough task. In this, the operating system mainly kills that process, which does not work more till now.

Kill all Process: – Kill all the processes is not a suitable approach. We can use this approach when the problem becomes critical. By killing all the processes, the system efficiency will be decreased, and we have to execute all the processes further from the start.

Pin It on Pinterest

Share This