summaryrefslogtreecommitdiff
path: root/spinlock.c
diff options
context:
space:
mode:
Diffstat (limited to 'spinlock.c')
-rw-r--r--spinlock.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/spinlock.c b/spinlock.c
index 2e604b7..f814632 100644
--- a/spinlock.c
+++ b/spinlock.c
@@ -51,10 +51,9 @@ acquire(struct spinlock *lock)
while(cmpxchg(0, 1, &lock->locked) == 1)
;
- // Now that lock is acquired, make sure
- // we wait for all pending writes from other
- // processors.
- cpuid(0, 0, 0, 0, 0); // memory barrier
+ // Serialize instructions: now that lock is acquired, make sure
+ // we wait for all pending writes from other processors.
+ cpuid(0, 0, 0, 0, 0); // memory barrier (see Ch 7 of IA-32 manual, vol 3)
// Record info about lock acquisition for debugging.
// The +10 is only so that we can tell the difference
@@ -74,9 +73,9 @@ release(struct spinlock *lock)
lock->pcs[0] = 0;
lock->cpu = 0xffffffff;
- // Before unlocking the lock, make sure to flush
- // any pending memory writes from this processor.
- cpuid(0, 0, 0, 0, 0); // memory barrier
+ // Serialize instructions: before unlocking the lock, make sure
+ // to flush any pending memory writes from this processor.
+ cpuid(0, 0, 0, 0, 0); // memory barrier (see Ch 7 of IA-32 manual, vol 3)
lock->locked = 0;
if(--cpus[cpu()].nlock == 0)