Skip to main content

Deadlock and Coffman conditions

Short answer

Deadlock is a cycle of tasks each holding a resource and waiting for another held within the set. The four necessary Coffman conditions are mutual exclusion, hold-and-wait, no preemption, and circular wait. All must hold for deadlock to occur.

Define deadlock and explain the Coffman conditions (conditions favoring deadlock).

A deadlock is a situation in which two or more tasks (processes) are each waiting for a resource held by another in the set, so none of them can proceed. Example: task T1 holds resource R1 and waits for R2, while T2 holds R2 and waits for R1.

   T1 --holds--> R1 <--waits-- T2
   T1 --waits--> R2 --held by-- T2

Coffman conditions

Deadlock can occur only if all four hold at the same time:

  1. Mutual exclusion: at least one resource can be used by only one task at a time (non-shareable).
  2. Hold and wait: a task holds at least one resource while waiting for additional resources held by others.
  3. No pre-emption: a resource cannot be forcibly taken from a task; the task must release it voluntarily.
  4. Circular wait: there is a closed chain of tasks, each waiting for a resource held by the next one in the chain.

Handling: prevent by removing any one condition (e.g. request all resources at once, impose a resource ordering), avoid (Banker's algorithm), detect and recover, or ignore.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Embedded System chapter 6 questions →