aboutsummaryrefslogtreecommitdiff
path: root/kernel/spinlock.c
diff options
context:
space:
mode:
authorRobert Morris <rtm@csail.mit.edu>2019-10-27 08:03:19 -0400
committerRobert Morris <rtm@csail.mit.edu>2019-10-27 08:03:19 -0400
commitd9160fb4b98e3ce04d3928c1fbd2ec26b3cc746a (patch)
treefd89ac93ce4ee9a628307d2983c017c1a5510736 /kernel/spinlock.c
parentf2ab0eb644a60f946f35fcb5578fba53720edfa7 (diff)
downloadxv6-labs-2022-d9160fb4b98e3ce04d3928c1fbd2ec26b3cc746a.tar.xz
xv6-labs-2022-d9160fb4b98e3ce04d3928c1fbd2ec26b3cc746a.zip
nits
Diffstat (limited to 'kernel/spinlock.c')
-rw-r--r--kernel/spinlock.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/kernel/spinlock.c b/kernel/spinlock.c
index f192832..9840302 100644
--- a/kernel/spinlock.c
+++ b/kernel/spinlock.c
@@ -72,13 +72,12 @@ release(struct spinlock *lk)
}
// Check whether this cpu is holding the lock.
+// Interrupts must be off.
int
holding(struct spinlock *lk)
{
int r;
- push_off();
r = (lk->locked && lk->cpu == mycpu());
- pop_off();
return r;
}
@@ -103,9 +102,9 @@ pop_off(void)
struct cpu *c = mycpu();
if(intr_get())
panic("pop_off - interruptible");
- c->noff -= 1;
- if(c->noff < 0)
+ if(c->noff < 1)
panic("pop_off");
+ c->noff -= 1;
if(c->noff == 0 && c->intena)
intr_on();
}