From 46bbd72f3eeaff9386b2a90af88f3d46b458a0e8 Mon Sep 17 00:00:00 2001 From: rtm Date: Sat, 15 Jul 2006 12:03:57 +0000 Subject: no more recursive locks wakeup1() assumes you hold proc_table_lock sleep(chan, lock) provides atomic sleep-and-release to wait for condition ugly code in swtch/scheduler to implement new sleep fix lots of bugs in pipes, wait, and exit fix bugs if timer interrupt goes off in schedule() console locks per line, not per byte --- trap.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'trap.c') diff --git a/trap.c b/trap.c index 6f5409b..66b15e0 100644 --- a/trap.c +++ b/trap.c @@ -36,8 +36,14 @@ trap(struct Trapframe *tf) { int v = tf->tf_trapno; + if(cpus[cpu()].clis){ + cprintf("cpu %d v %d eip %x\n", cpu(), v, tf->tf_eip); + panic("interrupt while interrupts are off"); + } + if(v == T_SYSCALL){ struct proc *cp = curproc[cpu()]; + int num = cp->tf->tf_regs.reg_eax; if(cp == 0) panic("syscall with no proc"); if(cp->killed) @@ -50,6 +56,14 @@ trap(struct Trapframe *tf) panic("trap ret but not RUNNING"); if(tf != cp->tf) panic("trap ret wrong tf"); + if(cp->locks){ + cprintf("num=%d\n", num); + panic("syscall returning locks held"); + } + if(cpus[cpu()].clis) + panic("syscall returning but clis != 0"); + if((read_eflags() & FL_IF) == 0) + panic("syscall returning but FL_IF clear"); if(read_esp() < (unsigned)cp->kstack || read_esp() >= (unsigned)cp->kstack + KSTACKSIZE) panic("trap ret esp wrong"); @@ -61,14 +75,20 @@ trap(struct Trapframe *tf) if(v == (IRQ_OFFSET + IRQ_TIMER)){ struct proc *cp = curproc[cpu()]; lapic_timerintr(); + if(cp && cp->locks) + panic("timer interrupt while holding a lock"); if(cp){ - if(cpus[cpu()].clis != 0) - panic("trap clis > 0"); +#if 1 + if((read_eflags() & FL_IF) == 0) + panic("timer interrupt but interrupts now disabled"); +#else cpus[cpu()].clis += 1; sti(); +#endif if(cp->killed) proc_exit(); - yield(); + if(cp->state == RUNNING) + yield(); } return; } -- cgit v1.2.3