From 48755214c9a02d6249caf3126d3b41d67eda4730 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sun, 30 Aug 2009 23:02:08 -0700 Subject: assorted fixes: * rename c/cp to cpu/proc * rename cpu.context to cpu.scheduler * fix some comments * formatting for printout --- spinlock.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'spinlock.c') 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(); } -- cgit v1.2.3