aboutsummaryrefslogtreecommitdiff
path: root/kernel/spinlock.c
diff options
context:
space:
mode:
authorRobert Morris <rtm@csail.mit.edu>2019-10-03 15:02:19 -0400
committerRobert Morris <rtm@csail.mit.edu>2019-10-03 15:02:19 -0400
commit56583b1402a7f8fad0f8c3c296e26f12b1114c95 (patch)
tree68ea77f02de3b3dabea5c976f6bac571be0478d6 /kernel/spinlock.c
parent78f863f8aead6346dfdfc62e91af25c9383e25a7 (diff)
downloadxv6-labs-2022-56583b1402a7f8fad0f8c3c296e26f12b1114c95.tar.xz
xv6-labs-2022-56583b1402a7f8fad0f8c3c296e26f12b1114c95.zip
updated alarmtest
Diffstat (limited to 'kernel/spinlock.c')
-rw-r--r--kernel/spinlock.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/kernel/spinlock.c b/kernel/spinlock.c
index 563532e..f192832 100644
--- a/kernel/spinlock.c
+++ b/kernel/spinlock.c
@@ -34,7 +34,8 @@ acquire(struct spinlock *lk)
// Tell the C compiler and the processor to not move loads or stores
// past this point, to ensure that the critical section's memory
- // references happen after the lock is acquired.
+ // references happen strictly after the lock is acquired.
+ // On RISC-V, this emits a fence instruction.
__sync_synchronize();
// Record info about lock acquisition for holding() and debugging.
@@ -52,8 +53,10 @@ release(struct spinlock *lk)
// Tell the C compiler and the CPU to not move loads or stores
// past this point, to ensure that all the stores in the critical
- // section are visible to other CPUs before the lock is released.
- // On RISC-V, this turns into a fence instruction.
+ // section are visible to other CPUs before the lock is released,
+ // and that loads in the critical section occur strictly before
+ // the lock is released.
+ // On RISC-V, this emits a fence instruction.
__sync_synchronize();
// Release the lock, equivalent to lk->locked = 0.