Card 08/ 08
Recap: Deadlock and the Failures Near It
The cycle, the four conditions, the ordering fix, and the stalls that look like it, with where each was.
Deadlock and its neighbours come down to the five ideas below, each listed with the card that covers it.
| The idea | Where |
|---|---|
| A deadlock is a cycle of threads each holding what another wants | Deadlock: Two Threads Each Waiting for the Other's Lock |
| Two correct methods taking the same locks in opposite orders are enough | Deadlock Example: A Transfer Run in Both Directions at Once |
| Four conditions must hold at once; removing any one prevents it | The Four Conditions for Deadlock |
| A global lock order removes circular wait at no cost | Preventing Deadlock With a Global Lock Order |
| Idle and stuck is deadlock; busy and stuck is livelock | Deadlock vs Livelock vs Starvation |
No single method can deadlock on its own, so no amount of reading one method will find it. A deadlock comes from two pieces of code disagreeing about an order, and the fix is a decision the whole program keeps.
← → move through sections and cards