IT lexicon › Programming › Seqlock

Seqlock

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

Lightweight synchronization where readers check a sequence counter before and after reading to detect concurrent writers.

A seqlock is a simple alternative to read-write-lock when writes are rare. A global counter increments before and after each write. Readers sample the counter, fetch data, then sample again — if the values differ, a write occurred in between. Readers never acquire locks and are never blocked; they simply retry on conflict.

Seqlocks are lock-free for readers but assume data is small enough to read atomically or that "dirty reads" during a retry are acceptable. The Linux kernel uses them for time-of-day data and other frequently-read values.

← Back to the lexicon