---
title: "Deadlock conditions and why all necessary"
subject: "Operating System"
chapter: 7
key: "semester_6/operating_system:deadlock-conditions-why-necessary"
source: https://www.bctengineer.com/q/semester_6/operating_system/deadlock-conditions-why-necessary
site: BCT Engineering
---

# Deadlock conditions and why all necessary

Operating System · Chapter 7: Deadlock

- Asked in: 2070 Bhadra, 10 marks
- Video: [Lec19 Deadlock | Necessary conditions for Deadlock | Operating Systems](https://www.youtube.com/watch?v=x9FF723STvo) — Jenny's Lectures CS IT
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_6/operating_system/deadlock-conditions-why-necessary
- Whole chapter: https://www.bctengineer.com/md/semester_6/operating_system/chapter-7

## Question

What is deadlock? State the necessary conditions for deadlock to occur. Give reason why all conditions are necessary.

## Short answer

Deadlock is a situation where processes block forever holding resources and waiting for others. The four necessary conditions are mutual exclusion, hold and wait, no preemption, and circular wait. All are necessary because breaking any one prevents deadlock; each removes a possible escape path.

## Answer

#### Deadlock
Deadlock is a situation in which two or more processes are blocked forever, each holding a resource and waiting for another resource held by some other process in the set.

#### Necessary conditions
1. **Mutual exclusion:** at least one resource is non-sharable, i.e. used by one process at a time.
2. **Hold and wait:** a process holds one resource while waiting for another.
3. **No preemption:** a granted resource can be released only by its holder.
4. **Circular wait:** processes P0, P1, …, Pn form a cycle where Pi waits for a resource held by P(i+1) and Pn waits for one held by P0.

#### Why all are necessary
Deadlock exists only when all four hold together, because each condition removes one way out.

- **Without mutual exclusion:** if resources were sharable (like read-only files), no process would ever need to wait for a resource, so no one would block.
- **Without hold and wait:** if a process had to request all its resources at once, or release what it holds before asking for more, it would never wait while holding something, so it could not block others.
- **Without no preemption:** if the OS could take a resource from a waiting process and give it to another, the blocked process would be unblocked and the chain would break.
- **Without circular wait:** if resources are ordered and requested in increasing order, the wait graph has no cycle; the last process in the chain always gets its resource and finishes, releasing resources for the others.

The first three conditions describe the environment in which deadlock can happen (they are policies of the system), and circular wait is the actual blocking situation. Since breaking any one of them prevents deadlock, each is necessary; since none is enough on its own, all four must hold together.

**Example:** P holds the printer and wants the scanner; Q holds the scanner and wants the printer. The printer and scanner are exclusive, each process holds and waits, neither resource can be preempted, and the waits form a cycle. If any one condition fails, deadlock does not occur.

## Check yourself

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

1. Why can deadlock not occur without mutual exclusion?
   A. Resources are preempted
   B. Sharable resources never force a process to wait
   C. Processes request in order
   D. Processes release all resources
   Answer: B. If nothing is exclusive, no one blocks. (Key point: Without mutual exclusion)

2. How can hold and wait be avoided?
   A. Request all resources at once or release held ones before asking more
   B. Order resources numerically
   C. Let the OS take resources back
   D. Make resources sharable
   Answer: A. Then a process never waits while holding something. (Key point: Breaking hold and wait)

3. How does resource ordering prevent circular wait?
   A. Processes are aborted when they wait
   B. All resources are given at start
   C. Requests in increasing order give no cycle, so the last process in the chain always gets its resource
   D. Resources are made sharable
   Answer: C. Without a cycle, the chain ends in a process that can finish. (Key point: Breaking circular wait)

4. How does allowing preemption break deadlock?
   A. It removes the need for resources
   B. It makes resources sharable
   C. It orders requests
   D. The OS takes a resource from a waiting process and gives it to another, unblocking the chain
   Answer: D. A preempted resource frees the blocked chain. (Key point: Breaking no preemption)

## Related in Operating System

- [Deadlock; necessary conditions with examples](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Adeadlock-necessary-conditions-examples) — Operating System, chapter 7
- [Necessary conditions; deadlock prevention](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Adeadlock-prevention-necessary-conditions) — Operating System, chapter 7
- [Deadlock conditions, detection, action](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Adeadlock-conditions-detection-recovery-action) — Operating System, chapter 7
- [Four deadlock conditions; prevention, recovery](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Adeadlock-conditions-prevention-recovery) — Operating System, chapter 7
- [Deadlock conditions; Banker's safe sequence](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Afour-conditions-banker-snapshot-332) — 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

## 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 and its conditions](https://www.bctengineer.com/question.md?key=semester_4%2Fmicroprocessor%3Adeadlock-conditions) — Microprocessor, chapter 6, asked 2×
- [Need of transaction; phantom deadlock](https://www.bctengineer.com/question.md?key=semester_7%2Fdistributed_system%3Atransaction-deadlock-phantom) — Distributed System, chapter 8
