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

# Deadlock and its conditions

Microprocessor · Chapter 6: Advanced Topics

- Asked in: 2072 Magh, 1+3 marks; 2070 Bhadra, 4 marks (asked 2 times)
- 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-conditions
- Whole chapter: https://www.bctengineer.com/md/semester_4/microprocessor/chapter-6

## Question

What is deadlock? What are the conditions for deadlock to occur?

## Short answer

Deadlock is permanent blocking where each process holds a resource and waits for another held by someone else. It needs four conditions together: mutual exclusion, hold and wait, no preemption, and circular wait.

## Answer

#### Deadlock

A **deadlock** is a situation in which a set of processes is blocked permanently because each process holds a resource and waits for another resource held by some other process in the set. None of them can proceed.

**Example:** process P1 holds the printer and requests the scanner; process P2 holds the scanner and requests the printer. Both wait for ever.

#### Necessary conditions (Coffman conditions)

Deadlock can occur only if all four conditions hold at the same time.

1. **Mutual exclusion:** at least one resource is non-shareable, so only one process can use it at a time.
2. **Hold and wait:** a process holding at least one resource is waiting to acquire more resources held by others.
3. **No preemption:** a resource cannot be forcibly taken from a process; it is released only voluntarily after use.
4. **Circular wait:** there is a closed chain of processes P1 → P2 → … → Pn → P1, where each process waits for a resource held by the next.

```text
 P1 holds R1, wants R2
 P2 holds R2, wants R1
   P1 --wants--> R2 --held by--> P2
   P2 --wants--> R1 --held by--> P1   (cycle)
```

Deadlock is prevented by making at least one of these four conditions impossible.

## Check yourself

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

1. What is deadlock?
   A. Processes permanently blocked, each holding a resource and waiting for one held by another
   B. A process using the CPU too long
   C. A crash from memory overflow
   D. Processes waiting briefly for I/O
   Answer: A. None of the processes in the set can proceed. (Key point: Definition)

2. Which set lists the four necessary conditions?
   A. Mutual exclusion, starvation, preemption, circular wait
   B. Mutual exclusion, hold and wait, no preemption, circular wait
   C. Hold and wait, aging, no preemption, mutual exclusion
   D. Spooling, hold and wait, preemption, safe state
   Answer: B. All four must hold at the same time for deadlock to be possible. (Key point: Four conditions)

3. What is circular wait?
   A. A closed chain of processes where each waits for a resource held by the next
   B. A process waiting for itself forever in a loop of instructions
   C. Two processes sharing a resource at the same time
   D. A resource that cannot be shared
   Answer: A. P1 waits for P2, ..., Pn waits for P1. (Key point: Circular wait)

4. How is deadlock prevented?
   A. By making all four conditions true
   B. By ignoring requests
   C. By making at least one of the four conditions impossible
   D. By increasing CPU speed
   Answer: C. Deadlock needs all four, so removing one prevents it. (Key point: Prevention)

## Related in other subjects

- [Deadlock and Coffman conditions](https://www.bctengineer.com/question.md?key=semester_6%2Fembedded_system%3Acoffman-deadlock) — Embedded System, chapter 6, asked 4×
- [Deadlock; necessary conditions with examples](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Adeadlock-necessary-conditions-examples) — Operating System, chapter 7
- [Deadlock conditions; Banker's with 4 processes](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Afour-conditions-banker-p1-p4) — Operating System, chapter 7
- [Deadlock conditions and why all necessary](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Adeadlock-conditions-why-necessary) — Operating System, chapter 7
