CSS Optional — Paper-II, Section-A · P-II.III.IV · The single most numerically-tested OS subtopic — a Banker's Algorithm or Resource-Allocation-Graph question is nearly guaranteed most years.
All four must hold simultaneously for deadlock to be possible:
An edge Pi → Rj means Pi has requested Rj; Rj → Pi means Rj is allocated to Pi.
| Strategy | Idea | Cost |
|---|---|---|
| Prevention | Design the system so at least one Coffman condition can never hold | Restricts resource-usage patterns, can hurt utilization |
| Avoidance | Grant a request only if the resulting state is still "safe" (Banker's Algorithm) | Needs advance knowledge of each process's maximum claim |
| Detection & Recovery | Let deadlocks happen; periodically run a detection algorithm (cycle search); recover by killing/preempting a process | Overhead of periodic checks + cost of recovery (lost work) |
| Ignorance ("Ostrich Algorithm") | Assume deadlocks are rare enough to just ignore | Simplest — used by most general-purpose OSes (Windows, Linux) |
Denying conditions for Prevention (the most-asked pairing):
Data structures (n processes, m resource types): Available[m], Max[n][m] (each process's maximum claim), Allocation[n][m] (currently held), Need[n][m] = Max − Allocation.
Safety Algorithm: find some order in which every process's Need can be satisfied using Available plus resources released by processes finishing earlier in that order. If a complete such sequence exists, the state is safe.