IT lexicon › Programming › Sequential-lock

Sequential-lock

Programming På svenska → Updated: 2026-11-15

A lock variant optimized for many readers and few writers, letting readers work without taking any lock.

A sequential lock (or seqlock) works by maintaining a counter that increments on every write. A reader samples the counter before and after reading the data — if it's unchanged and even, the read is valid. If it's odd or has changed, the read is retried. Only writers hold an actual lock.

Seqlocks are much faster than read-write-locks for read-heavy workloads because readers never execute atomic operations. The Linux kernel uses them everywhere for syscall arguments and time readings. The downside is that reads may fail and retry, and writers cannot read their own values while holding the lock (they don't see their own writes until after release).

← Back to the lexicon