summaryrefslogtreecommitdiff
path: root/spinlock.c
diff options
context:
space:
mode:
authorrtm <rtm>2006-07-29 09:35:02 +0000
committerrtm <rtm>2006-07-29 09:35:02 +0000
commit32630628a996e29018641af262272339ed6fef88 (patch)
tree73c9a7dee75f96c0ce0e9c804d379dd60bf254b4 /spinlock.c
parente46fb46fcf4302bf5ed913101c5c7b510fe03ad4 (diff)
downloadxv6-labs-32630628a996e29018641af262272339ed6fef88.tar.gz
xv6-labs-32630628a996e29018641af262272339ed6fef88.tar.bz2
xv6-labs-32630628a996e29018641af262272339ed6fef88.zip
open()
Diffstat (limited to 'spinlock.c')
-rw-r--r--spinlock.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/spinlock.c b/spinlock.c
index 171afaf..bde6e46 100644
--- a/spinlock.c
+++ b/spinlock.c
@@ -8,7 +8,7 @@
// Can't call cprintf from inside these routines,
// because cprintf uses them itself.
-#define cprintf dont_use_cprintf
+//#define cprintf dont_use_cprintf
extern int use_console_lock;
@@ -21,8 +21,12 @@ getcallerpc(void *v)
void
acquire(struct spinlock * lock)
{
- if(holding(lock))
+ if(holding(lock)){
+ extern use_console_lock;
+ use_console_lock = 0;
+ cprintf("lock %s pc %x\n", lock->name ? lock->name : "", lock->pc);
panic("acquire");
+ }
if(cpus[cpu()].nlock++ == 0)
cli();
@@ -31,6 +35,7 @@ acquire(struct spinlock * lock)
cpuid(0, 0, 0, 0, 0); // memory barrier
lock->pc = getcallerpc(&lock);
lock->cpu = cpu();
+ cpus[cpu()].lastacquire = lock;
}
void
@@ -39,6 +44,7 @@ release(struct spinlock * lock)
if(!holding(lock))
panic("release");
+ cpus[cpu()].lastrelease = lock;
cpuid(0, 0, 0, 0, 0); // memory barrier
lock->locked = 0;
if(--cpus[cpu()].nlock == 0)