AlgoViz

Threads, locks and lost progress

easy 8 min

Threads in a process share memory and descriptors.

Where it shows up

The same pattern appears across everyday software.

  • A slow dependency inside a critical section

    A profile shows idle CPUs during a throughput collapse. A lock-wait trace shows many callers behind one owner that is waiting for a remote write. Compare hold time with wait time before changing the primitive. Moving work out of a lock changes the atomic boundary, so reserve or snapshot the state under the lock and validate it when the write finishes.

  • Verifying the intervention

    Move the call outside the critical section with a version check. Verify invariants under concurrency. If hold times stay short while queues grow, measure arrival rate and the number of acquisitions per request.