summaryrefslogtreecommitdiff
path: root/spinlock.c
diff options
context:
space:
mode:
Diffstat (limited to 'spinlock.c')
-rw-r--r--spinlock.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/spinlock.c b/spinlock.c
index a30fc58..b194211 100644
--- a/spinlock.c
+++ b/spinlock.c
@@ -36,6 +36,13 @@ getcallerpcs(void *v, uint pcs[])
pcs[i] = 0;
}
+// Check whether this cpu is holding the lock.
+int
+holding(struct spinlock *lock)
+{
+ return lock->locked && lock->cpu == cpu() + 10;
+}
+
// Acquire the lock.
// Loops (spins) until the lock is acquired.
// (Because contention is handled by spinning,
@@ -83,11 +90,3 @@ release(struct spinlock *lock)
if(--cpus[cpu()].nlock == 0)
sti();
}
-
-// Check whether this cpu is holding the lock.
-int
-holding(struct spinlock *lock)
-{
- return lock->locked && lock->cpu == cpu() + 10;
-}
-