Synchronization and Deadlocks

  • Semaphores as a core primitive
  • Blocking and wakeup invariants
  • Deadlock detection via cycles
1 / 5

Semaphores

  • P blocks if count == 0
  • V wakes one waiter
  • Queue order matters
2 / 5

Deadlock

  • Wait-for graph cycle
  • No progress possible
3 / 5

Prevention vs detection

  • Prevention: ordering
  • Detection: cycle finding
4 / 5

What you will build

  • Semaphore simulator
  • Deadlock detector
5 / 5
Use arrow keys or click edges to navigate. Press H to toggle help, F for fullscreen.