summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Morris <[email protected]>2016-09-08 14:45:20 -0400
committerRobert Morris <[email protected]>2016-09-08 14:45:20 -0400
commit34c2efc1d063f4b366c1017c174d117cc96eb990 (patch)
tree074f1a1c717530404dabeb15e548985269801dfa
parentd63ac118e817ecab6fd4f890960f4f73b4dfd5e8 (diff)
downloadxv6-labs-34c2efc1d063f4b366c1017c174d117cc96eb990.tar.gz
xv6-labs-34c2efc1d063f4b366c1017c174d117cc96eb990.tar.bz2
xv6-labs-34c2efc1d063f4b366c1017c174d117cc96eb990.zip
use asm() for lock release, not a C assignment
-rw-r--r--spinlock.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/spinlock.c b/spinlock.c
index bf863ef..7b372ef 100644
--- a/spinlock.c
+++ b/spinlock.c
@@ -59,8 +59,10 @@ release(struct spinlock *lk)
// stores; __sync_synchronize() tells them both to not re-order.
__sync_synchronize();
- // Release the lock.
- lk->locked = 0;
+ // Release the lock, equivalent to lk->locked = 0.
+ // This code can't use a C assignment, since it might
+ // not be atomic.
+ asm volatile("movl $0, %0" : "+m" (lk->locked) : );
popcli();
}