The implementation first checks whether the value at the address still contains the value userspace expects, then goes to sleep. That is racy, since the value can be changed by another thread in between the check and the thread going to sleep. In fact, the whole point of FUTEX_WAIT
having this argument is so that the kernel should (somehow) make this check without racing, since the userspace cannot.
serenity/Kernel/Syscalls/futex.cpp
Lines 50 to 68 in d410449
The happy path always returns 0, but at least FUTEX_WAKE
is supposed to return the number of threads actually woken.
serenity/Kernel/Syscalls/futex.cpp
Line 83 in d410449
If we want to port RWLock
and CondVar
from LWSP π, we need to support FUTEX_REQUEUE
and FUTEX_WA{IT,KE}_BITSET
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too