Apex › Systems & OS

futex — the fast userspace mutex

Why a modern mutex is nearly free when uncontended. The lock word lives in userspace, so locking a free mutex or unlocking one with no waiters is a single atomic compare-and-swap — no system call. Only blocking on a held lock or waking a waiter traps into the kernel. Pick a workload and watch which operations stay in userspace and which pay for the kernel.

More in Systems & OS