Practice free →
HomeGATE CSEcomputerscienceOperating Systems › Suppose thread A acquires lock L1, then thread B…

Suppose thread A acquires lock L1, then thread B acquires lock L2. Now A tries to acquire L2 while B tries to acquire L1. What is this situation called?

AStarvation
BRace condition
CPriority inversion
DDeadlock
Answer & Solution
Correct answer: D. Deadlock
1. DEADLOCK occurs when two or more threads are each waiting for resources held by the other(s) — none can proceed. 2. The example above: A holds L1, wants L2; B holds L2, wants L1. Neither can advance until the other releases — they're locked in a permanent wait. 3. Four CONDITIONS for deadlock (Coffman conditions): mutual exclusion + hold-and-wait + no preemption + circular wait. All four must hold for deadlock to occur. 4. STARVATION (option A) is different: a thread is repeatedly skipped by the scheduler but isn't fundamentally blocked. RACE (option B) is incorrect ordering of independent ops. PRIORITY INVERSION (option C) is when a low-priority thread holds a lock a high-priority thread needs. _Source: OSTEP Ch 32 (Deadlock — referenced from Ch 28) + general OS theory._
Solve this in the app — GATE CSE practice & 24k+ MCQs →
Related questions