Futex
Fast Userspace Mutual Exclusive is a kernel feature. It helps userspace apps build MUTEX solutions. It sleeps and wakes threads based on the lock state.
- An app thread calls Futex to drop out of scheduling. It waits until another thread releases the lock.
- Futex holds a hash map of memory addresses and blocked threads.
- A second thread holds the lock. When it sets the memory address to free, it also calls Futex with a WAKE_UP command for that address.
- Futex then wakes all the threads that were blocked.
All programming languages use this feature inside to provide locking and synchronization.
Lock address
This can be any address tied to the app. For example, it can be the address of a lock property on the object.
