diff options
author | Russ Cox <rsc@swtch.com> | 2009-08-30 23:02:08 -0700 |
---|---|---|
committer | Russ Cox <rsc@swtch.com> | 2009-08-30 23:02:08 -0700 |
commit | 48755214c9a02d6249caf3126d3b41d67eda4730 (patch) | |
tree | 2edc8b996fd7c3ef2da8876d657140e242999d93 /spinlock.c | |
parent | 0aef8914959af9e472852611eb6352c211093d35 (diff) | |
download | xv6-labs-48755214c9a02d6249caf3126d3b41d67eda4730.tar.gz xv6-labs-48755214c9a02d6249caf3126d3b41d67eda4730.tar.bz2 xv6-labs-48755214c9a02d6249caf3126d3b41d67eda4730.zip |
assorted fixes:
* rename c/cp to cpu/proc
* rename cpu.context to cpu.scheduler
* fix some comments
* formatting for printout
Diffstat (limited to 'spinlock.c')
-rw-r--r-- | spinlock.c | 19 |
1 files changed, 8 insertions, 11 deletions
@@ -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(); } |