summaryrefslogtreecommitdiff
path: root/spinlock.c
diff options
context:
space:
mode:
authorrsc <rsc>2007-08-22 06:01:32 +0000
committerrsc <rsc>2007-08-22 06:01:32 +0000
commiteaea18cb9cbb86018dae8f1decfa217ecbe85fa5 (patch)
tree98c4a9b852ad9b6aaf16016417cf5eeee0b3857e /spinlock.c
parent3dcf889c1b5c2c5ddf5b4756f2a731c344f6f08e (diff)
downloadxv6-labs-eaea18cb9cbb86018dae8f1decfa217ecbe85fa5.tar.gz
xv6-labs-eaea18cb9cbb86018dae8f1decfa217ecbe85fa5.tar.bz2
xv6-labs-eaea18cb9cbb86018dae8f1decfa217ecbe85fa5.zip
PDF at http://am.lcs.mit.edu/~rsc/xv6.pdf
Various changes made while offline. + bwrite sector argument is redundant; use b->sector. + reformatting of files for nicer PDF page breaks + distinguish between locked, unlocked inodes in type signatures + change FD_FILE to FD_INODE + move userinit (nee proc0init) to proc.c + move ROOTDEV to param.h + always parenthesize sizeof argument
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;
-}
-