diff options
author | Robert Morris <[email protected]> | 2019-06-06 13:54:03 -0400 |
---|---|---|
committer | Robert Morris <[email protected]> | 2019-06-06 13:54:03 -0400 |
commit | 91ba81110acd3163f7de3580b677eece0c57f5e7 (patch) | |
tree | 670536a7f365e75282048b5447a107338b677642 /spinlock.c | |
parent | 8607051b5fc79fffa319b913b19e99bc5b90e063 (diff) | |
download | xv6-labs-91ba81110acd3163f7de3580b677eece0c57f5e7.tar.gz xv6-labs-91ba81110acd3163f7de3580b677eece0c57f5e7.tar.bz2 xv6-labs-91ba81110acd3163f7de3580b677eece0c57f5e7.zip |
gdb backtraces: -ggdb, -fno-omit-frame-pointer, BSIZE=1024
Diffstat (limited to 'spinlock.c')
-rw-r--r-- | spinlock.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -56,11 +56,13 @@ release(struct spinlock *lk) // section are visible to other cores before the lock is released. // Both the C compiler and the hardware may re-order loads and // stores; __sync_synchronize() tells them both not to. + // On RISC-V, this turns into a fence instruction. __sync_synchronize(); // Release the lock, equivalent to lk->locked = 0. // This code can't use a C assignment, since it might // not be atomic. A real OS would use C atomics here. + // On RISC-V, use an amoswap instruction. //asm volatile("movl $0, %0" : "+m" (lk->locked) : ); __sync_lock_release(&lk->locked); @@ -73,7 +75,7 @@ holding(struct spinlock *lk) { int r; push_off(); - r = lk->locked && lk->cpu == mycpu(); + r = (lk->locked && lk->cpu == mycpu()); pop_off(); return r; } |