CS Atlas GATE 2027
Operating Systems course
0 / 58 complete

Operating Systems/Phase 4 · Deadlock

Chapter review LI-4.1 · Item 33 of 58

Chapter 4.1 Lock-in

Read at your own pace. Try the questions before opening the answers.

On this page

Phase 4Ch 4.1 Deadlock

ACompressed recap

Four conditions (mutual exclusion, hold and wait, no pre-emption, circular wait). RAG: request P → R, assignment R → P; cycle + single instances = deadlock; multiple instances = maybe. Prevention: break a condition (resource ordering breaks circular wait). Avoidance: banker's, Need = Max − Allocation, safe sequence; unsafe ≠ deadlock. Detection: Request ≤ Work; wait-for graph for single instances. No deadlock ⟺ R ≥ Σ(kᵢ − 1) + 1.

BMerged rule card

4.1.1 Deadlock: the four conditions and resource-allocation graphs

  • Deadlock: each process in a set waits for something only another in the set can give.
  • Four necessary conditions: mutual exclusion, hold and wait, no pre-emption, circular wait.
  • RAG: request P → R, assignment R → P. No cycle → no deadlock; cycle + single instances → deadlock; cycle + multiple instances → maybe.
  • Starvation ≠ deadlock.

4.1.2 Prevention and avoidance: safe states and the banker's algorithm

  • Prevention breaks a condition: all-at-once requests (hold and wait), pre-emption, resource ordering (circular wait).
  • Safe state: some order lets everyone finish. Unsafe ≠ deadlock.
  • Banker's: Need = Max − Allocation; Work = Available; pick Need ≤ Work; Work += Allocation; all finish → safe.
  • Request: ≤ Need, ≤ Available, pretend, check safety; grant only if safe.

4.1.3 Detection, recovery, and the minimum-resources formula

  • Strategies: prevention, avoidance, detection + recovery, ignore (ostrich).
  • Single instances: wait-for graph cycle = deadlock. Multiple: matrix detection with Request ≤ Work.
  • Recovery: kill all / one at a time; pre-empt with victim + rollback (avoid starving one victim).
  • No deadlock ⟺ R ≥ Σ(kᵢ − 1) + 1; n equal processes: R ≥ n(k − 1) + 1.

CInterleaved GATE-style questions

Q1 · MCQ · 1 mark(s) — Conditions

Which condition says a resource can't be taken away from the process holding it?

  1. (A) No pre-emption
  2. (B) Circular wait
  3. (C) Hold and wait
  4. (D) Mutual exclusion

Q2 · MCQ · 1 mark(s) — RAG

A resource-allocation graph has no cycle. Then:

  1. (A) the system is unsafe
  2. (B) the system is deadlocked
  3. (C) the system is not deadlocked
  4. (D) it depends on the number of instances

Q3 · NAT · 2 mark(s) — Banker's

One resource, 12 units. A holds 5 (max 10), B holds 2 (max 4), C holds 2 (max 9). How many units are free?

Numerical answer: ________

Q4 · MCQ · 2 mark(s) — Banker's

In the same state (12 units; A 5/10, B 2/4, C 2/9), C asks for 1 more unit. What happens?

  1. (A) Granted: still safe
  2. (B) C waits: the new state would be unsafe
  3. (C) Granted: banker's never refuses
  4. (D) Error: exceeds C's maximum

Q5 · MCQ · 1 mark(s) — Prevention

Making a process request all its resources before it starts breaks:

  1. (A) hold and wait
  2. (B) mutual exclusion
  3. (C) circular wait
  4. (D) no pre-emption

Q6 · NAT · 1 mark(s) — Minimum resources

5 processes each need at most 3 units. Minimum units so that deadlock can never occur?

Numerical answer: ________

Q7 · NAT · 2 mark(s) — Maximum K

4 processes share 9 units; each needs at most K. Largest K that guarantees no deadlock?

Numerical answer: ________

Q8 · MCQ · 1 mark(s) — Detection

In the detection algorithm, a process is assumed able to finish when:

  1. (A) it has the highest priority
  2. (B) its Allocation ≤ Work
  3. (C) its Max ≤ Work
  4. (D) its current Request ≤ Work

DAnswer Vault

Try the questions first. Open when you are ready to check.

🔐 Open the Answer Vault

Q1 Answer: (A) · 1 mark(s)

Only voluntary release.

  • (B) is wrong: About the cycle.
  • (C) is wrong: About holding while waiting.
  • (D) is wrong: About sharing.

Re-read: Lesson 4.1.1 — Deadlock: the four conditions and resource-allocation graphs

Q2 Answer: (C) · 1 mark(s)

No cycle, no deadlock.

  • (A) is wrong: Unrelated statement.
  • (B) is wrong: Needs a cycle.
  • (D) is wrong: Only matters when there is a cycle.

Re-read: Lesson 4.1.1 — Deadlock: the four conditions and resource-allocation graphs

Q3 Answer: 3 · 2 mark(s)

12 − 9.

Re-read: Lesson 4.1.2 — Prevention and avoidance: safe states and the banker's algorithm

Q4 Answer: (B) · 2 mark(s)

Free 2: B finishes (free 4), but A needs 5 and C needs 6.

  • (A) is wrong: No safe sequence remains.
  • (C) is wrong: It refuses unsafe requests.
  • (D) is wrong: 3 ≤ 9.

Re-read: Lesson 4.1.2 — Prevention and avoidance: safe states and the banker's algorithm

Q5 Answer: (A) · 1 mark(s)

It never holds while waiting.

  • (B) is wrong: Resources are still exclusive.
  • (C) is wrong: Not directly.
  • (D) is wrong: Nothing is pre-empted.

Re-read: Lesson 4.1.2 — Prevention and avoidance: safe states and the banker's algorithm

Q6 Answer: 11 · 1 mark(s)

5 × 2 + 1.

Re-read: Lesson 4.1.3 — Detection, recovery, and the minimum-resources formula

Q7 Answer: 3 · 2 mark(s)

4(K − 1) + 1 ≤ 9 → K ≤ 3.

Re-read: Lesson 4.1.3 — Detection, recovery, and the minimum-resources formula

Q8 Answer: (D) · 1 mark(s)

Detection uses current requests.

  • (A) is wrong: Priority is irrelevant.
  • (B) is wrong: Allocation is what it gives back.
  • (C) is wrong: That is avoidance thinking (and uses Need).

Re-read: Lesson 4.1.3 — Detection, recovery, and the minimum-resources formula

Ready for the next idea?

Mark this item complete when you’ve finished reading and working through it.