From 8b4e2a08febc8b957b44732dbc7da831479a0005 Mon Sep 17 00:00:00 2001 From: rtm Date: Sat, 1 Jul 2006 21:26:01 +0000 Subject: swtch saves callee-saved registers swtch idles on per-CPU stack, not on calling process's stack fix pipe bugs usertest.c tests pipes, fork, exit, close --- trap.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'trap.c') diff --git a/trap.c b/trap.c index 01c2f14..e36540d 100644 --- a/trap.c +++ b/trap.c @@ -35,16 +35,28 @@ trap(struct Trapframe *tf) { int v = tf->tf_trapno; + if(tf->tf_cs == 0x8 && kernel_lock == cpu()) + cprintf("cpu %d: trap from %x:%x with lock=%d\n", + cpu(), tf->tf_cs, tf->tf_eip, kernel_lock); + acquire_spinlock(&kernel_lock); // released in trapret in trapasm.S if(v == T_SYSCALL){ - curproc[cpu()]->tf = tf; + struct proc *cp = curproc[cpu()]; + cp->tf = tf; syscall(); + if(cp != curproc[cpu()]) + panic("trap ret wrong curproc"); + if(cp->state != RUNNING) + panic("trap ret but not RUNNING"); + if(tf != cp->tf) + panic("trap ret wrong tf"); + if(read_esp() < cp->kstack || read_esp() >= cp->kstack + KSTACKSIZE) + panic("trap ret esp wrong"); return; } if(v == (IRQ_OFFSET + IRQ_TIMER)){ - curproc[cpu()]->tf = tf; lapic_timerintr(); return; } -- cgit v1.2.3