diff options
| author | Robert Morris <rtm@csail.mit.edu> | 2016-09-08 14:45:20 -0400 | 
|---|---|---|
| committer | Robert Morris <rtm@csail.mit.edu> | 2016-09-08 14:45:20 -0400 | 
| commit | 34c2efc1d063f4b366c1017c174d117cc96eb990 (patch) | |
| tree | 074f1a1c717530404dabeb15e548985269801dfa | |
| parent | d63ac118e817ecab6fd4f890960f4f73b4dfd5e8 (diff) | |
| download | xv6-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.c | 6 | 
1 files changed, 4 insertions, 2 deletions
| @@ -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();  } | 
