operating-systems concurrency

Definition

Circular Wait

Circular wait is a condition in a concurrent system where a closed chain of processes exists such that each process holds at least one resource needed by the next process in the chain.

It is the fourth of the Coffman conditions and the only one that describes a specific sequence of events rather than a static system property. A deadlock occurs if and only if a circular wait exists and cannot be resolved using the existing system protocols (Mutual Exclusion, Hold and Wait, No Preemption).

Resolution via Linear Ordering

A circular wait can be prevented by imposing a strict linear ordering on all resource types. If every process is forced to request resources in increasing order of their rank, a cycle becomes mathematically impossible.

Prevention of Circular Wait

Assume a circular wait exists under a linear ordering protocol.

  1. Process holds resource and requests . The protocol requires .
  2. Process holds resource and requests . The protocol requires .
  3. By induction, for the chain to reach , we must have .
  4. For the cycle to close, (holding ) must request . This requires .
  5. This implies , which is a contradiction. Thus, no cycle can form.