提交 34c2efc1 创建 作者: Robert Morris's avatar Robert Morris

use asm() for lock release, not a C assignment

上级 d63ac118
...@@ -59,8 +59,10 @@ release(struct spinlock *lk) ...@@ -59,8 +59,10 @@ release(struct spinlock *lk)
// stores; __sync_synchronize() tells them both to not re-order. // stores; __sync_synchronize() tells them both to not re-order.
__sync_synchronize(); __sync_synchronize();
// Release the lock. // Release the lock, equivalent to lk->locked = 0.
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(); popcli();
} }
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论