SpinLockWait: Fixes unexpected lock success

With a contended unique lock, we forgot to reset the `Expected` value to
zero. This was causing a contended mutex to incorrectly succeed.

Noticed this when converting some pthread mutexes over to spinloops to
remove strace noise.

The reference wfe_mutex library I wrote didn't have this problem since
the implementation is slightly different.
This commit is contained in:
Ryan Houdek 2024-02-03 01:10:57 -08:00
parent 557cb593e1
commit cce6011205

View File

@ -259,6 +259,7 @@ namespace FEXCore::Utils::SpinWaitLock {
do {
// Wait until the futex is unlocked.
Wait(Futex, 0);
Expected = 0;
} while (!AtomicFutex->compare_exchange_strong(Expected, Desired));
}