Skip to content

Commit 77c9ce0

Browse files
committed
mutex: Check spin flag with atomic load before exchange
1 parent 0a0c8dd commit 77c9ce0

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

mcfgthread/mutex.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ _MCF_mutex_lock_slow(_MCF_mutex* mutex, const int64_t* timeout_opt)
9595
YieldProcessor();
9696

9797
/* Wait for my turn. */
98+
if(_MCF_atomic_load_b_rlx(do_spin_byte_ptr(mutex, my_mask)) == false)
99+
continue;
100+
98101
if(_MCF_atomic_xchg_b_rlx(do_spin_byte_ptr(mutex, my_mask), false) == false)
99102
continue;
100103

0 commit comments

Comments
 (0)