Synchronization and deadlock
Making threads take turns with locks and semaphores, the classic buffer problem, and how a system gets into, avoids and recovers from deadlock.
About 6 hours of study
Learning objectives
- Protect a critical section with a lock or a semaphore
- Build a bounded buffer with three semaphores
- Run the banker's algorithm and detect a cycle in a wait-for graph
Lessons
- 1
Synchronization: locks and semaphores Intermediate
The critical-section problem and its three rules, Peterson's solution, hardware atomic instructions, mutex locks, semaphores, and the producer-consumer, readers-writers and dining-philosophers problems.
- 2
Deadlock Intermediate
When processes wait for each other forever: the four conditions, resource-allocation graphs, prevention, avoidance with the banker's algorithm, and detection and recovery.
Module practice
- Counting a semaphoreEasy
- The bounded bufferMedium
- Semaphores with wait queuesHard
- The need matrixEasy
- Find the deadlockMedium
- Is the state safe?Hard
Module quiz
‹ CPU schedulingMemory: allocation, paging and virtual memory ›