On 05/02/21 18:31, Laszlo Ersek wrote:
On 02/05/21 18:21, Paolo Bonzini wrote:
On 05/02/21 17:56, Laszlo Ersek wrote:
No concern that the store might not be atomic?
221 SPIN_LOCK *That would be overkill. However, it *is* buggy because it is missing a
223 ReleaseSpinLock (
224 IN OUT SPIN_LOCK *SpinLock
227 SPIN_LOCK LockValue;
229 ASSERT (SpinLock != NULL);
231 LockValue = *SpinLock;
232 ASSERT (LockValue == SPIN_LOCK_ACQUIRED || LockValue ==
234 _ReadWriteBarrier ();
235 *SpinLock = SPIN_LOCK_RELEASED;
236 _ReadWriteBarrier ();
238 return SpinLock;
Fishy. I would have implemented it with another
InterlockedCompareExchangePointer(), and maybe ASSERT()ed on the
original value returned by the InterlockedCompareExchangePointer().
(processor) barrier on non-x86 architectures and has a useless barrier
after the store. Instead it should be just this:
*SpinLock = SPIN_LOCK_RELEASED;
Not as long as it's a pointer or smaller.