operating-systems concurrency

Definition

Indirect Deadlock Prevention

Indirect deadlock prevention is a strategy that aims to prevent deadlocks by invalidating one of the three system-level Coffman conditions: Mutual Exclusion, Hold and Wait, or No Preemption.

Strategies

Breaking Mutual Exclusion

This condition is a fundamental requirement for many resources (e.g., a printer cannot be shared simultaneously). However, it can sometimes be “broken” using spooling, which makes a non-shareable resource appear shareable to user processes by queuing their requests in a buffer.

Breaking Hold and Wait

This requires a process to request all of its required resources at once.

  • Protocol: The process is blocked until every resource in the request can be granted simultaneously.
  • Drawbacks:
    • Inefficiency: Resources are held for much longer than they are actually needed.
    • Future Knowledge: The process must know its total resource requirements in advance.
    • Starvation: A process requiring many resources may wait indefinitely if at least one is always held by others.

Breaking No Preemption

This allows the OS to forcibly reclaim resources from processes.

  • Process-Initiated: If a process holding resources is denied a new request, it must release all its current resources and request them again.
  • OS-Initiated: If process requests a resource held by , the OS may preempt process (if is blocked) and give its resources to .
  • Feasibility: This is only practical for resources whose state can be easily saved and restored, such as the CPU (via context switching) or memory (via swapping).