Skip to main content

Deadlock and its conditions

Short answer

Deadlock is permanent blocking where each process holds a resource and waits for another held by someone else. It needs four conditions together: mutual exclusion, hold and wait, no preemption, and circular wait.

What is deadlock? What are the conditions for deadlock to occur?

Deadlock

A deadlock is a situation in which a set of processes is blocked permanently because each process holds a resource and waits for another resource held by some other process in the set. None of them can proceed.

Example: process P1 holds the printer and requests the scanner; process P2 holds the scanner and requests the printer. Both wait for ever.

Necessary conditions (Coffman conditions)

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

  1. Mutual exclusion: at least one resource is non-shareable, so only one process can use it at a time.
  2. Hold and wait: a process holding at least one resource is waiting to acquire more resources held by others.
  3. No preemption: a resource cannot be forcibly taken from a process; it is released only voluntarily after use.
  4. Circular wait: there is a closed chain of processes P1 → P2 → … → Pn → P1, where each process waits for a resource held by the next.
 P1 holds R1, wants R2
 P2 holds R2, wants R1
   P1 --wants--> R2 --held by--> P2
   P2 --wants--> R1 --held by--> P1   (cycle)

Deadlock is prevented by making at least one of these four conditions impossible.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Microprocessor chapter 6 questions →