Concurrency from Zero

Why counter++ loses updates, how locks deadlock, what the hardware reorders, and how to write code that survives all of it.

14 LESSONS~220 MIN
START WITH DATA RACE ▸ DRILL MODE ⏱

BEFORE YOU START

This path assumes you can already do the following. Each line says where ATLAS teaches it.

  1. 01 DATA RACE counter++ is three instructions, not one L215 MIN
  2. 02 LOST UPDATE Two clients, one row, last write wins L215 MIN
  3. 03 CHECK-THEN-ACT if (!exists) insert — still racy L212 MIN
  4. 04 TOCTOU Time-of-Check to Time-of-Use L215 MIN
  5. 05 PUBLICATION Visible before it's ready L318 MIN
  6. 06 REENTRANCY The DAO, in miniature L215 MIN
  7. 07 DEADLOCK Both holding, both waiting L215 MIN
  8. 08 ABA Same value, different world L318 MIN
  9. 09 MESI Every core sees every write, and the bus bills you for it L215 MIN
  10. 10 MEMORY ORDERING Your stores can arrive in a different order than you wrote them L218 MIN
  11. 11 LOCKS, ATOMICS, LOCK-FREE Three ways to make one update safe, three different costs L215 MIN
  12. 12 EVENT LOOP STARVATION One long task and every other request waits L112 MIN
  13. 13 LIVELOCK & PRIORITY INVERSION Everyone is busy, nothing gets done L215 MIN
  14. 14 CAPSTONE: CONNECTION POOLCAPSTONE Everything in this path, in one 40-line class L320 MIN
COMING TO THIS PATH