Apex › Systems & OS

The seqlock (sequence lock)

How the kernel lets millions of readers per second read a multi-word value (like the clock) without locking or blocking — while a writer updates it. The writer brackets its update with an odd-then-even counter; a reader snapshots the counter, reads the data, and re-checks — retrying if the counter was odd or changed. Step through an interleaving and watch a naive read tear while the seqlock read retries; proven across all 70 interleavings.

More in Systems & OS