do not call proc_exit until lock dropped
This commit is contained in:
parent
1baead533f
commit
4c917f6df2
1 changed files with 18 additions and 20 deletions
22
trap.c
22
trap.c
|
@ -76,29 +76,27 @@ trap(struct trapframe *tf)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if(cp) {
|
if(cp == 0) {
|
||||||
// Assume process divided by zero or dereferenced null, etc.
|
|
||||||
cprintf("pid %d %s: trap %d err %d on cpu %d eip %x -- kill proc\n",
|
|
||||||
cp->pid, cp->name, tf->trapno, tf->err, cpu(), tf->eip);
|
|
||||||
proc_exit();
|
|
||||||
}
|
|
||||||
// Otherwise it's our mistake.
|
// Otherwise it's our mistake.
|
||||||
cprintf("unexpected trap %d from cpu %d eip %x\n",
|
cprintf("unexpected trap %d from cpu %d eip %x\n",
|
||||||
tf->trapno, cpu(), tf->eip);
|
tf->trapno, cpu(), tf->eip);
|
||||||
panic("trap");
|
panic("trap");
|
||||||
}
|
}
|
||||||
|
// Assume process divided by zero or dereferenced null, etc.
|
||||||
|
cprintf("pid %d %s: trap %d err %d on cpu %d eip %x -- kill proc\n",
|
||||||
|
cp->pid, cp->name, tf->trapno, tf->err, cpu(), tf->eip);
|
||||||
|
cp->killed = 1;
|
||||||
|
}
|
||||||
cpus[cpu()].nlock--;
|
cpus[cpu()].nlock--;
|
||||||
|
|
||||||
if(tf->trapno == IRQ_OFFSET + IRQ_TIMER && cp != 0){
|
|
||||||
// Force process exit if it has been killed and is in user space.
|
// Force process exit if it has been killed and is in user space.
|
||||||
// (If it is still executing in the kernel, let it keep running
|
// (If it is still executing in the kernel, let it keep running
|
||||||
// until it gets to the regular system call return.)
|
// until it gets to the regular system call return.)
|
||||||
if((tf->cs&3) == DPL_USER && cp->killed)
|
if(cp && cp->killed && (tf->cs&3) == DPL_USER)
|
||||||
proc_exit();
|
proc_exit();
|
||||||
|
|
||||||
// Force process to give up CPU and let others run.
|
// Force process to give up CPU on clock tick.
|
||||||
// If locks were held with interrupts on, would need to check nlock.
|
// If interrupts were on while locks held, would need to check nlock.
|
||||||
if(cp->state == RUNNING)
|
if(cp && cp->state == RUNNING && tf->trapno == IRQ_OFFSET+IRQ_TIMER)
|
||||||
yield();
|
yield();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue