summaryrefslogtreecommitdiff
path: root/spinlock.c
diff options
context:
space:
mode:
authorFrans Kaashoek <[email protected]>2011-08-29 17:18:40 -0400
committerFrans Kaashoek <[email protected]>2011-08-29 17:18:40 -0400
commit1ddfbbb194e3aa668b33469eb547132a7a7f940a (patch)
tree41ad0ae10ef2743c6e9433e711358dede77ce041 /spinlock.c
parent22f7db5336cb20c82eb1ffa45c0ef63825442c95 (diff)
downloadxv6-labs-1ddfbbb194e3aa668b33469eb547132a7a7f940a.tar.gz
xv6-labs-1ddfbbb194e3aa668b33469eb547132a7a7f940a.tar.bz2
xv6-labs-1ddfbbb194e3aa668b33469eb547132a7a7f940a.zip
Revert "Introduce and use sleeplocks instead of BUSY flags"
My changes have a race with re-used bufs and the code doesn't seem to get shorter Keep the changes that fixed ip->off race This reverts commit 3a5fa7ed9020eaf8ab843a16d26db7393b2ec072. Conflicts: defs.h file.c file.h
Diffstat (limited to 'spinlock.c')
-rw-r--r--spinlock.c42
1 files changed, 4 insertions, 38 deletions
diff --git a/spinlock.c b/spinlock.c
index c1f6a96..a16621c 100644
--- a/spinlock.c
+++ b/spinlock.c
@@ -17,9 +17,10 @@ initlock(struct spinlock *lk, char *name)
lk->cpu = 0;
}
-// Acquire a spin lock. Loops (spins) until the lock is acquired.
-// Holding a lock for a long time may cause other CPUs to waste time spinning to acquire it.
-// Spinlocks shouldn't be held across sleep(); for those cases, use sleeplocks.
+// Acquire the lock.
+// Loops (spins) until the lock is acquired.
+// Holding a lock for a long time may cause
+// other CPUs to waste time spinning to acquire it.
void
acquire(struct spinlock *lk)
{
@@ -114,38 +115,3 @@ popcli(void)
sti();
}
-void
-initsleeplock(struct sleeplock *l)
-{
- l->locked = 0;
-}
-
-// Grab the sleeplock that is protected by spinl. Sleeplocks allow a process to lock
-// a data structure for long times, including across sleeps. Other processes that try
-// to acquire a sleeplock will be put to sleep when another process hold the sleeplock.
-// To update status of the sleeplock atomically, the caller must hold spinl
-void
-acquire_sleeplock(struct sleeplock *sleepl, struct spinlock *spinl)
-{
- while (sleepl->locked) {
- sleep(sleepl, spinl);
- }
- sleepl->locked = 1;
-}
-
-// Release the sleeplock that is protected by a spin lock
-// Caller must hold the spinlock that protects the sleeplock
-void
-release_sleeplock(struct sleeplock *sleepl)
-{
- sleepl->locked = 0;
- wakeup(sleepl);
-}
-
-// Is the sleeplock acquired?
-// Caller must hold the spinlock that protects the sleeplock
-int
-acquired_sleeplock(struct sleeplock *sleepl)
-{
- return sleepl->locked;
-}