[Locks] Can we change while loop of MCSParking lock to If statement?
Coll1ns-cult opened this issue · 2 comments
Coll1ns-cult commented
Hi I wonder if we can change the following statement
while unsafe { (*node).locked.load(Acquire) } { thread::park(); }
to this:
if unsafe { (*node).locked.load(Acquire) } { thread::park(); }
Since we can only unpark() this thread with the lock holder thread, while loop is not a necessity I believe. Is this a valid implementation?
Thanks in Advance!
m-spitfire commented
The park
call may have spurious wake up. So it's necessary to be in a loop.
Coll1ns-cult commented
Thanks!