operating-systems concurrency

Definition

Coffman Conditions

The Coffman conditions are four necessary requirements that must hold simultaneously for a deadlock to occur. Identified by E. G. Coffman, Jr. in 1971.

For a deadlock to exist, all four conditions must be present:

  1. Mutual Exclusion: At least one resource is non-shareable; only one process may use it at a time.
  2. Hold and Wait: A process holds at least one resource while waiting to acquire others held by different processes.
  3. No Preemption: Resources cannot be forcibly removed; they must be released voluntarily.
  4. Circular Wait: A closed chain exists where each process holds a resource needed by the next in the chain.

Prevention

Deadlock management requires breaking at least one condition:

Break Mutual Exclusion

Use spooling or shareable data structures where possible (not always feasible for inherently exclusive resources like printers).

Break Hold and Wait

Require processes to request all resources at once, or release held resources before requesting new ones.

Break No Preemption

Allow the operating system to forcibly reclaim resources from processes when necessary.

Break Circular Wait

Impose a linear ordering on resource types; processes must request resources in increasing order.