---
title: "Deadlock, postponement, prevention, 2 processes"
subject: "Operating System"
chapter: 7
key: "semester_6/operating_system:deadlock-postponement-two-process-three-resource"
source: https://www.bctengineer.com/q/semester_6/operating_system/deadlock-postponement-two-process-three-resource
site: BCT Engineering
---

# Deadlock, postponement, prevention, 2 processes

Operating System · Chapter 7: Deadlock

- Asked in: 2074 Bhadra, 1+1+3+3+2 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-postponement-two-process-three-resource
- Whole chapter: https://www.bctengineer.com/md/semester_6/operating_system/chapter-7

## Question

What is Deadlock and indefinite Postponement? Explain the necessary conditions for deadlock and explain how deadlock can be prevented. A system has 2 processes and 3 resources. Each process needs maximum of two resources. Is deadlock possible? Explain.

## Short answer

Deadlock is a circular wait for resources; indefinite postponement is starvation. The four conditions are mutual exclusion, hold and wait, no preemption, and circular wait. Prevention attacks one condition via spooling, requesting all resources at once, allowing preemption, or resource ordering. With two processes each needing max two of three resources, deadlock is impossible because at least one process can always obtain its maximum need.

## Answer

#### Deadlock (1 mark)
Deadlock is a state where each process of a set waits for a resource held by another process of the set, so none can continue.

#### Indefinite postponement (1 mark)
A process is delayed repeatedly, for an unbounded time, while other processes are served (also called starvation). Example: a low-priority process never scheduled because high-priority ones keep arriving. Unlike deadlock, the system as a whole keeps working.

#### Necessary conditions (3 marks)
1. **Mutual exclusion:** a resource is used by one process at a time.
2. **Hold and wait:** a process holds resources while requesting more.
3. **No preemption:** a resource cannot be taken away forcibly.
4. **Circular wait:** a circular chain of waiting processes exists.

#### Prevention (3 marks)
- Remove mutual exclusion by spooling.
- Remove hold and wait: request all resources at once.
- Allow preemption of resources.
- Impose a total ordering on resources and request in order, which prevents circular wait.

#### Two processes, three resources (2 marks)
Each process needs at most 2 resources. Worst case: each process holds 1 resource and waits for its second one. Together they hold 2 resources, so 3 − 2 = 1 resource is free. That free resource can be given to either process, which then has its 2 resources, finishes and releases both. The other process then gets its second resource.

```text
 P1 holds 1 | P2 holds 1 | 1 free
 give free to P1 -> P1 finishes, releases 2
 P2 now gets its second -> finishes
```

In general, deadlock-free if Σ(maxᵢ − 1) + 1 ≤ R, i.e. (2−1)+(2−1)+1 = 3 ≤ 3.

**Answer: Deadlock is not possible**, because at least one process can always obtain its maximum need.

## Check yourself

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

1. Which describes indefinite postponement?
   A. All processes wait for each other's resources
   B. The system halts completely
   C. A process terminates with an error
   D. A process is delayed for an unbounded time while others are served, though the system as a whole keeps working
   Answer: D. Unlike deadlock, only some process is starved, e.g. low priority never scheduled. (Key point: Starvation)

2. How is circular wait prevented?
   A. Make every resource sharable by spooling
   B. Make processes request all resources before starting
   C. Number resource types and allow requests only in increasing order
   D. Preempt the resources of waiting processes
   Answer: C. With an ordered request rule no cycle of waiting processes can form. (Key point: Circular wait prevention)

3. Each of 2 processes needs at most 2 of 3 resources. Is deadlock possible?
   A. No; in the worst case each holds 1, one resource is free and one process can finish
   B. Yes; each holds 1 and both wait forever
   C. Yes; each holds 2 and waits for a third
   D. No, because the processes never need a second resource
   Answer: A. Worst case holds 2 resources, leaving 1 free, so one process obtains its max, finishes and releases. (Key point: 2 processes, 3 resources)

4. Which condition guarantees deadlock freedom?
   A. Sum of max_i > R
   B. Sum of (max_i - 1) + 1 <= R; here (1)+(1)+1 = 3 <= 3
   C. Sum of max_i - 1 >= R
   D. Number of processes > number of resources
   Answer: B. The worst case uses sum(max_i-1) resources; one more resource lets some process finish. (Key point: Formula)

## Related in Operating System

- [Deadlock vs postponement; Banker's 4 resources](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Adeadlock-vs-postponement-banker-6442) — 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; 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; 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 and why all necessary](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Adeadlock-conditions-why-necessary) — 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

## 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×
- [Capital budgeting needs, steps, process](https://www.bctengineer.com/question.md?key=semester_7%2Fproject_engineering%3Acapital-budgeting-needs-steps-process) — Project Engineering, chapter 6
- [Air-fuel mixture needs at different operating conditions](https://www.bctengineer.com/question.md?key=semester_5%2Fautomotive_technology%3Aair-fuel-mixture-requirements) — Automotive Technology, chapter 2
