Concurrency

Spinlock

A lock implemented with a busy-wait loop instead of going to sleep.


In plain terms

Right when contention is rare and critical sections are short (microseconds). Wrong almost everywhere else — burns CPU.

Origin

Edsger Dijkstra's 1965 paper on the dining-philosophers problem introduced the busy-wait lock. Modern variants (MCS, ticket) target NUMA fairness.

Where it shows up in production
  • Linux spinlock_t Used for very short critical sections in the kernel — interrupt handlers, scheduler internals.
  • Rust parking_lot::Mutex Spins briefly before parking the thread. Best of both worlds.
Sources & further reading
Found this useful?