---
title: "Short note: deadlock and its remedies"
subject: "Microprocessor"
chapter: 6
key: "semester_4/microprocessor:deadlock-and-remedies"
source: https://www.bctengineer.com/q/semester_4/microprocessor/deadlock-and-remedies
site: BCT Engineering
---

# Short note: deadlock and its remedies

Microprocessor · Chapter 6: Advanced Topics

- Asked in: 2074 Bhadra, 4 marks
- Video: [L-4.1: DEADLOCK concept | Example | Necessary condition | Operating System](https://www.youtube.com/watch?v=rWFH6PLOIEI) — Gate Smashers
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_4/microprocessor/deadlock-and-remedies
- Whole chapter: https://www.bctengineer.com/md/semester_4/microprocessor/chapter-6

## Question

Write a short note on Deadlock and its remedies.

## Short answer

Remedies are prevention (break one of the four Coffman conditions), avoidance (Banker's algorithm, grant only safe requests), detection and recovery (wait-for graph cycle; terminate or preempt), or ignore the problem as in Windows/UNIX.

## Answer

**Deadlock** is a state in which a set of processes are all blocked, each waiting for a resource that is held by another process in the set, so none can continue. It needs four conditions together: mutual exclusion, hold and wait, no preemption and circular wait.

#### Remedies

1. **Deadlock prevention:** make at least one condition impossible.
   - Mutual exclusion: use spooling and make resources shareable where possible.
   - Hold and wait: a process must request all its resources at once, or release what it holds before requesting more.
   - No preemption: allow the OS to take resources away from a waiting process.
   - Circular wait: number the resource types and require requests in increasing order.
2. **Deadlock avoidance:** the OS checks each request and grants it only if the system stays in a *safe state* (a state where all processes can still finish). The **Banker's algorithm** is the common method; it needs advance knowledge of maximum needs.
3. **Deadlock detection and recovery:** allow deadlock to happen, detect it with a resource-allocation graph or wait-for graph (a cycle means deadlock for single-instance resources). Recover by terminating one or more processes, or by preempting resources and rolling back a process.
4. **Ignore the problem (ostrich method):** used by Windows and UNIX since deadlocks are rare and prevention is costly.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. How is circular wait prevented?
   A. Number the resource types and request them in increasing order
   B. Allow resources to be shared always
   C. Terminate any waiting process
   D. Request resources at random
   Answer: A. Ordered requests make a cycle impossible. (Key point: Prevention of circular wait)

2. What does deadlock avoidance (Banker's algorithm) do?
   A. Grants a request only if the system stays in a safe state, using advance knowledge of maximum needs
   B. Lets deadlock occur and then detects it
   C. Ignores the problem
   D. Kills processes randomly
   Answer: A. A safe state means all processes can still finish. (Key point: Avoidance)

3. How is deadlock detected for single-instance resources?
   A. By a long CPU burst
   B. By a cycle in the resource-allocation or wait-for graph
   C. By a full disk
   D. By a missing file
   Answer: B. A cycle in the graph means deadlock for single-instance resources. (Key point: Detection)

4. How can hold and wait be eliminated?
   A. A process requests all resources at once or releases held ones before requesting more
   B. Resources are made non-preemptive
   C. Resources are numbered
   D. The process waits indefinitely
   Answer: A. This ensures no process holds some resources while waiting for others. (Key point: Hold and wait)
