- 2072 Magh · 2+6 marks
Avoidance, detection, prevention techniques
Short answer
Avoidance grants requests only if the system stays in a safe state (Banker's algorithm). Detection lets deadlock occur, then finds it via graph or matrix and recovers. Prevention breaks one condition: share resources, request all at once, preempt if blocked, or impose a resource ordering to prevent circular wait.
What is deadlock avoidance and detection? Explain all possible deadlock prevention techniques.
Deadlock avoidance
The OS has advance information on the maximum resources each process may request. It grants a request only if the resulting state is safe, i.e. there is some order in which all processes can complete. The Banker's algorithm (Dijkstra) is the standard method. Unsafe states are not necessarily deadlocked, but are avoided.
Deadlock detection
The system does not prevent or avoid deadlock; it lets it occur, then detects it by examining a resource allocation graph (cycle means deadlock) or by the matrix detection algorithm, and recovers by terminating processes or preempting resources.
Deadlock prevention techniques
Prevention ensures that at least one of the four necessary conditions can never hold.
- Attacking mutual exclusion: make resources sharable where possible (e.g. spooling a printer so only the spooler daemon uses it). Not all resources can be shared.
- Attacking hold and wait: require a process to request all its resources before starting (or to release all it holds before asking for more). Drawbacks: low resource utilisation, starvation, and the need to know all requirements in advance.
- Attacking no preemption: if a process holding resources requests another one that is unavailable, all its held resources are preempted (released implicitly) and it restarts later when all can be had. Works for state-saveable resources (CPU registers, memory), not for printers.
- Attacking circular wait: number all resource types and require processes to request resources only in increasing numerical order (or hold only one at a time). A cycle can then never form. Drawback: finding a natural ordering that suits all processes is hard.
| Approach | Idea | Cost |
|---|---|---|
| Prevention | Break one condition | Low utilisation |
| Avoidance | Stay in safe state | Needs max claims |
| Detection | Find and recover | Recovery overhead |
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Deadlock occurrence and avoidance methods · Operating System, chapter 7
- Deadlock, postponement, prevention, 2 processes · Operating System, chapter 7
- Deadlock conditions, detection, action · Operating System, chapter 7
- Four deadlock conditions; prevention, recovery · Operating System, chapter 7
- Necessary conditions; deadlock prevention · Operating System, chapter 7
- Deadlock detection with allocation matrices · Operating System, chapter 7
- Lock, deadlock; deadlock avoidance · Distributed System, chapter 8
- Error detection in serial data transmission · Instrumentation II, chapter 3 · asked 2×
- Dataword vs codeword; error coding techniques · Data Communication, chapter 8
- Cavitation effects and prevention in reaction turbines · Hydropower Engineering, chapter 7