From 6eb6f10c5668bc2bdf5e561e0060e7e917ed55c1 Mon Sep 17 00:00:00 2001 From: rtm Date: Wed, 12 Jul 2006 15:35:33 +0000 Subject: passes both usertests exit had acquire where I meant release swtch now checks that you hold no locks --- proc.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'proc.c') diff --git a/proc.c b/proc.c index 53469a1..0e35540 100644 --- a/proc.c +++ b/proc.c @@ -181,7 +181,9 @@ swtch(int newstate) { struct proc *p = curproc[cpu()]; if(p == 0) - panic("swtch"); + panic("swtch no proc"); + if(p->locks != 0) + panic("swtch w/ locks"); p->newstate = newstate; // basically an argument to scheduler() if(setjmp(&p->jmpbuf) == 0) longjmp(&cpus[cpu()].jmpbuf); @@ -203,9 +205,11 @@ wakeup(void *chan) struct proc *p; acquire(&proc_table_lock); - for(p = proc; p < &proc[NPROC]; p++) - if(p->state == WAITING && p->chan == chan) + for(p = proc; p < &proc[NPROC]; p++){ + if(p->state == WAITING && p->chan == chan){ p->state = RUNNABLE; + } + } release(&proc_table_lock); } @@ -225,7 +229,7 @@ proc_exit() struct proc *cp = curproc[cpu()]; int fd; - cprintf("exit %x\n", cp); + cprintf("exit %x pid %d ppid %d\n", cp, cp->pid, cp->ppid); for(fd = 0; fd < NOFILE; fd++){ if(cp->fds[fd]){ @@ -246,7 +250,7 @@ proc_exit() if(p->ppid == cp->pid) p->pid = 1; - acquire(&proc_table_lock); + release(&proc_table_lock); // switch into scheduler swtch(ZOMBIE); @@ -265,10 +269,8 @@ cli(void) void sti(void) { - if(cpus[cpu()].clis < 1){ - cprintf("cpu %d clis %d\n", cpu(), cpus[cpu()].clis); + if(cpus[cpu()].clis < 1) panic("sti"); - } cpus[cpu()].clis -= 1; if(cpus[cpu()].clis < 1) __asm __volatile("sti"); -- cgit v1.2.3