summaryrefslogtreecommitdiff
path: root/spinlock.c
diff options
context:
space:
mode:
authorkaashoek <kaashoek>2006-09-08 14:36:44 +0000
committerkaashoek <kaashoek>2006-09-08 14:36:44 +0000
commit8e1d1ec934d5ebcd4d8208f88857be12c8a97a06 (patch)
tree9df339c0bcd494c2e60f63650cac001c62b1ebd2 /spinlock.c
parent50f88503664aae07e22e3ed2575853e396f909b5 (diff)
downloadxv6-labs-8e1d1ec934d5ebcd4d8208f88857be12c8a97a06.tar.gz
xv6-labs-8e1d1ec934d5ebcd4d8208f88857be12c8a97a06.tar.bz2
xv6-labs-8e1d1ec934d5ebcd4d8208f88857be12c8a97a06.zip
some comment changes
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)