For a deadlock to occur in a system, four conditions must hold simultaneously. These are called the Coffman Conditions (named after Edward G. Coffman Jr.).
1. Mutual Exclusion
Example: A printer cannot be shared between two processes simultaneously.
2. Hold and Wait
Example:
Process A holds a scanner and waits for a printer.
Process B holds the printer and waits for the scanner.
3. No Preemption
Example:
You can’t take back half-printed pages from a process unless it finishes printing.
4. Circular Wait
Example:
P1 waits for R2 (held by P2)
P2 waits for R3 (held by P3)
P3 waits for R1 (held by P1) → cycle → deadlock