Strategies for recovering from deadlocks
Deadlock recovery involves taking action to break a deadlock after it has been detected. Recovery strategies can be classified into process termination and resource preemption. Process termination approaches include: 1) Abort all deadlocked processes - simple but drastic, may cause significant work loss. 2) Abort processes one by one - more graceful but requires repeated deadlock detection. The choice of which process to terminate can be based on priority, computation time, resources held, or other factors. Resource preemption involves selecting a victim process and forcibly taking resources from it to break the deadlock. This requires: 1) Selecting a victim - based on cost factors like priority, execution time, or resources held. 2) Rollback - either complete rollback (restart process) or partial rollback (roll back to safe state). 3) Starvation prevention - ensuring the same process isn't always chosen as victim. Recovery strategies must consider the cost of recovery, including lost work, overhead, and potential starvation. The choice between termination and preemption depends on system requirements, process criticality, and the nature of the resources involved. Some systems use a combination of approaches, applying different recovery strategies to different types of processes or resources.