summaryrefslogtreecommitdiff
path: root/spinlock.c
diff options
context:
space:
mode:
Diffstat (limited to 'spinlock.c')
-rw-r--r--spinlock.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/spinlock.c b/spinlock.c
index a48e395..c3ea730 100644
--- a/spinlock.c
+++ b/spinlock.c
@@ -13,7 +13,7 @@ initlock(struct spinlock *lk, char *name)
{
lk->name = name;
lk->locked = 0;
- lk->cpu = 0xffffffff;
+ lk->cpu = 0;
}
// Acquire the lock.
@@ -34,10 +34,7 @@ acquire(struct spinlock *lk)
;
// Record info about lock acquisition for debugging.
- // The +10 is only so that we can tell the difference
- // between forgetting to initialize lock->cpu
- // and holding a lock on cpu 0.
- lk->cpu = cpu() + 10;
+ lk->cpu = cpu;
getcallerpcs(&lk, lk->pcs);
}
@@ -49,7 +46,7 @@ release(struct spinlock *lk)
panic("release");
lk->pcs[0] = 0;
- lk->cpu = 0xffffffff;
+ lk->cpu = 0;
// The xchg serializes, so that reads before release are
// not reordered after it. The 1996 PentiumPro manual (Volume 3,
@@ -87,7 +84,7 @@ getcallerpcs(void *v, uint pcs[])
int
holding(struct spinlock *lock)
{
- return lock->locked && lock->cpu == cpu() + 10;
+ return lock->locked && lock->cpu == cpu;
}
@@ -102,8 +99,8 @@ pushcli(void)
eflags = readeflags();
cli();
- if(c->ncli++ == 0)
- c->intena = eflags & FL_IF;
+ if(cpu->ncli++ == 0)
+ cpu->intena = eflags & FL_IF;
}
void
@@ -111,9 +108,9 @@ popcli(void)
{
if(readeflags()&FL_IF)
panic("popcli - interruptible");
- if(--c->ncli < 0)
+ if(--cpu->ncli < 0)
panic("popcli");
- if(c->ncli == 0 && c->intena)
+ if(cpu->ncli == 0 && cpu->intena)
sti();
}