Operating Systems · Revision notes

Process Synchronization & Deadlocks

When processes share data, uncontrolled interleaving causes race conditions. This chapter covers the critical-section problem, mutex locks and semaphores, the producer-consumer pattern, the four deadlock conditions, and handling deadlocks by prevention, avoidance (Banker’s algorithm) and detection.

Quick revision

  • Critical section: mutual exclusion, progress, bounded waiting
  • wait = P (decrement, block), signal = V (increment, wake)
  • Producer-consumer: empty=N, full=0, mutex=1; wait(mutex) after the counting semaphore
  • Deadlock needs mutual exclusion + hold&wait + no preemption + circular wait
  • Need = Max - Allocation; safe if a full sequence exists
  • Min resources for no deadlock: sum(max_i - 1) + 1
Read the full Process Synchronization & Deadlocks notes on Doubtclip →