None
EN
Landing a new syscall: What is futex?
['Landing A New Syscall', 'What Is Futex', 'André Almeida']
Collabora Newsroom RSS Feed
Even if the thread gets scheduled with the lock, any other thread that tries to change the account_balance would face the mutex_lock() and would have to wait until someone calls mutex_unlock() . mutex_lock(unsigned int *mutex) { while (!cmpxchg(mutex, UNLOCKED, LOCKED)) futex(mutex, FUTEX_WAIT, LOCKED); } mutex_unlock(unsigned int *mutex) { atomic_set(mutex, UNLOCKED); futex(mutex, FUTEX_WAKE, 1); }