From 0e84a0ec6e7893dad13dff9a958c5bc987b79c82 Mon Sep 17 00:00:00 2001 From: rtm Date: Tue, 8 Aug 2006 19:58:06 +0000 Subject: fix race in holding() check in acquire() give cpu1 a TSS and gdt for when it enters scheduler() and a pseudo proc[] entry for each cpu cpu0 waits for each other cpu to start up read() for files --- trap.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'trap.c') diff --git a/trap.c b/trap.c index ccbc754..7031223 100644 --- a/trap.c +++ b/trap.c @@ -34,6 +34,14 @@ void trap(struct trapframe *tf) { int v = tf->trapno; + + if(cpus[cpu()].nlock){ + cprintf("trap v %d eip %x cpu %d nlock %d\n", + v, tf->eip, cpu(), cpus[cpu()].nlock); + panic("interrupt while holding a lock"); + } + if((read_eflags() & FL_IF) == 0) + panic("interrupt but interrupts now disabled"); if(v == T_SYSCALL){ struct proc *cp = curproc[cpu()]; @@ -61,16 +69,13 @@ trap(struct trapframe *tf) panic("trap ret esp wrong"); if(cp->killed) proc_exit(); + // XXX probably ought to lgdt on trap return return; } if(v == (IRQ_OFFSET + IRQ_TIMER)){ struct proc *cp = curproc[cpu()]; lapic_timerintr(); - if(cpus[cpu()].nlock) - panic("timer interrupt while holding a lock"); - if((read_eflags() & FL_IF) == 0) - panic("timer interrupt but interrupts now disabled"); if(cp){ // Force process exit if it has been killed // and the interrupt came from user space. @@ -92,8 +97,5 @@ trap(struct trapframe *tf) return; } - - // XXX probably ought to lgdt on trap return - return; } -- cgit v1.2.3