Every shared-memory program eventually needs a mutex — a way to ensure that only one thread touches a critical section at a time. For decades the obvious tool was a kernel object: you called the OS to lock, and called it again to unlock. Every lock acquisition paid a round-trip through the kernel, even when no other thread was competing.
In 2002, Hubertus Franke, Matthew Kirkwood, Ingo Molnar and Rusty Russell introduced futexes (Fast Userspace muTEXes) in Linux. The key insight: when a lock is uncontended, you don't need the kernel at all. A single atomic compare-and-swap in userspace is enough to acquire it. The kernel only enters the picture when a thread must actually wait for a lock held by someone else.
That asymmetry — a handful of nanoseconds in the common case versus a syscall only when there is genuine contention — is why every modern threading library (pthreads, Java, Go, Rust's std::sync) is built on futexes under the hood.
Comments
Loading comments...