From: Marc-Aurel Zent <mzent@codeweavers.com> --- dlls/ntdll/sync.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/dlls/ntdll/sync.c b/dlls/ntdll/sync.c index e118cbee86a..77845d34216 100644 --- a/dlls/ntdll/sync.c +++ b/dlls/ntdll/sync.c @@ -846,8 +846,24 @@ static struct futex_queue *get_futex_queue( const void *addr ) static void spin_lock( LONG *lock ) { - while (InterlockedCompareExchange( lock, -1, 0 )) + unsigned int i; + + if (!InterlockedCompareExchange( lock, -1, 0 )) + return; + + for (i = 0; i < 64; i++) + { YieldProcessor(); + if (!ReadNoFence( lock ) && !InterlockedCompareExchange( lock, -1, 0 )) + return; + } + + for (;;) + { + NtYieldExecution(); + if (!ReadNoFence( lock ) && !InterlockedCompareExchange( lock, -1, 0 )) + return; + } } static void spin_unlock( LONG *lock ) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10829