Newer
Older
extern uint vectors[]; // in vectors.S: array of 256 entry pointers
SETGATE(idt[i], 0, SEG_KCODE<<3, vectors[i], 0);
SETGATE(idt[T_SYSCALL], 0, SEG_KCODE<<3, vectors[T_SYSCALL], DPL_USER);
if(cpu() == 0){
acquire(&tickslock);
ticks++;
wakeup(&ticks);
release(&tickslock);
// Assume process divided by zero or dereferenced null, etc.
cprintf("unexpected trap %d from cpu %d eip %x\n",
tf->trapno, cpu(), tf->eip);
if(tf->trapno == IRQ_OFFSET + IRQ_TIMER && cp != 0){
// 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
// until it gets to the regular system call return.)
if((tf->cs&3) == DPL_USER && cp->killed)
proc_exit();
// Force process to give up CPU and let others run.
// If locks were held with interrupts on, would need to check nlock.
if(cp->state == RUNNING)
yield();
}