Operating System Interview Questions · Question 17

What is the difference between deadlock, starvation and livelock?

Interview preparation resource from Gate Smashers.

Interview-ready answer

Deadlock means tasks are blocked in a dependency cycle, starvation means one task is repeatedly denied a needed resource, and livelock means tasks remain active but continually react without making useful progress.

Understand it clearly

In deadlock, the involved tasks cannot move because each is waiting. In starvation, the system as a whole may be healthy while unfair scheduling or allocation prevents one task from progressing for an unbounded time.

In livelock, tasks keep changing state, often to be polite to each other, but those changes repeatedly recreate the conflict. Fair queues and aging help starvation; consistent lock ordering helps deadlock; randomized backoff is a common livelock remedy.

These problems differ in their dependency. Deadlock involves a closed waiting relationship, starvation comes from unfair allocation, and livelock contains continuous activity without useful progress. The remedy must match the cause: ordering, fairness or randomized/back-off behaviour respectively.

Quick comparison
BasisDeadlockStarvation / livelock
MovementParticipants are blockedOne waits unfairly or all remain active
ProgressNone for the groupOthers progress or movement is useless
CauseCyclic dependencyUnfairness or repeated reactions
Typical fixOrdering or detectionAging, fairness or backoff