diff --git a/lib/spinlock.c b/lib/spinlock.c index 3f3e0d7..595432e 100644 --- a/lib/spinlock.c +++ b/lib/spinlock.c @@ -58,8 +58,8 @@ void acquire(struct spinlock *lk) { panic("acquire"); // Spin until aquired. See file header for details - while (__sync_lock_test_and_set(&lk->locked, 1) != 0) { - } + while (__sync_lock_test_and_set(&lk->locked, 1) != 0); + __sync_synchronize(); // No loads/stores after this point // Record info about lock acquisition for holding() and debugging.