- This technique does not attempt to prevent deadlocks; instead, it lets them occur
- The system detects when this happens, and then takes some action to recover after the fact (i.e., is reactive)
- With deadlock detection, requested resources are granted to processes whenever possible
- Periodically, the operating system performs an algorithm that allows it to detect the circular wait condition
- A check for deadlock can be made as frequently as resource request, or less frequently, depending on how likely it is for a deadlock to occur
- Checking at each resource request has two advantages: It leads to early detection, and the algorithm is relatively simple because it is based on incremental changes to the state of the system
- On the other hand, such frequent checks consume considerable processor time
- Once the deadlock algorithm has successfully detected a deadlock, some strategy is needed for recovery
- There are various ways:
- Recovery through Preemption; In some cases, it may be possible to temporarily take a resource away from its current owner and give it to another.
- Recovery through Rollback; If it is known that deadlocks are likely, one can arrange to have processes checkpointed periodically. For example, can undo transactions, thus free locks on database records. This often requires extra software functionality.
- Recovery through Termination; The most trivial way to break a deadlock is to kill one or more processes. One possibility is to kill a process in the cycle. Warning! Irrecoverable losses or erroneous results may occur, even if this is the least advanced process.
2004-05-25