progress

~/problems

Problems

Basics first, then the classics, then company-style assessments. Every problem has tests you run right here; multi-level ones unlock as you go. See the roadmap.

Locks

Deadlock and lock ordering

The four conditions and how to break one.

Main path: 4 problems, about 60 min.

Notes

The four Coffman conditions, which must all hold: mutual exclusion, hold-and-wait, no preemption, circular wait. Break any one of them.

Standard fix: a global lock order.

first, second = sorted((a, b))
with locks[first], locks[second]:
    ...

Other options: acquire(timeout=...) and back off, or a single lock (simple, but it serializes everything).

Gotchas: a -> b and b -> a transfers at once is the textbook deadlock. In the drills a deadlock shows up as a timeout.

5 problems

Concurrency

Locks Mutexes, lock ordering, readers and writers.

Deadlock and lock ordering guide

More practice: 1 problem
esc