summaryrefslogtreecommitdiff
path: root/proc.c
diff options
context:
space:
mode:
Diffstat (limited to 'proc.c')
-rw-r--r--proc.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/proc.c b/proc.c
index 4a05098..b3f352b 100644
--- a/proc.c
+++ b/proc.c
@@ -176,6 +176,15 @@ scheduler(void)
if(p->state == RUNNING)
panic("swtch to scheduler with state=RUNNING");
+ if(!holding(&proc_table_lock)){
+ cprintf("back to scheduler without proc_table_lock (pid=%d state=%d)", p->pid, p->state);
+ panic("scheduler lock");
+ }
+ if(cpus[cpu()].nlock != 1){
+ cprintf("holding %d locks in scheduler (pid=%d state=%d)\n", cpus[cpu()].nlock, p->pid, p->state);
+ panic("scheduler lock");
+ }
+
// XXX if not holding proc_table_lock panic.
}
release(&proc_table_lock);
@@ -236,6 +245,9 @@ sleep(void *chan, struct spinlock *lk)
if(p == 0)
panic("sleep");
+ if(lk == 0)
+ panic("sleep without lk");
+
// Must acquire proc_table_lock in order to
// change p->state and then call sched.
// Once we hold proc_table_lock, we can be