summaryrefslogtreecommitdiff
path: root/trap.c
diff options
context:
space:
mode:
authorrtm <rtm>2006-07-15 12:03:57 +0000
committerrtm <rtm>2006-07-15 12:03:57 +0000
commit46bbd72f3eeaff9386b2a90af88f3d46b458a0e8 (patch)
tree31ca93c160a10c50948329b30d27475aa6b38313 /trap.c
parentd9872ffa951291fcc3f7a92c0d235b86435c5714 (diff)
downloadxv6-labs-46bbd72f3eeaff9386b2a90af88f3d46b458a0e8.tar.gz
xv6-labs-46bbd72f3eeaff9386b2a90af88f3d46b458a0e8.tar.bz2
xv6-labs-46bbd72f3eeaff9386b2a90af88f3d46b458a0e8.zip
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
Diffstat (limited to 'trap.c')
-rw-r--r--trap.c26
1 files changed, 23 insertions, 3 deletions
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;
}