diff options
Diffstat (limited to 'trap.c')
-rw-r--r-- | trap.c | 24 |
1 files changed, 12 insertions, 12 deletions
@@ -37,18 +37,18 @@ void trap(struct trapframe *tf) { if(tf->trapno == T_SYSCALL){ - if(proc->killed) + if(myproc()->killed) exit(); - proc->tf = tf; + myproc()->tf = tf; syscall(); - if(proc->killed) + if(myproc()->killed) exit(); return; } switch(tf->trapno){ case T_IRQ0 + IRQ_TIMER: - if(cpunum() == 0){ + if(cpuid() == 0){ acquire(&tickslock); ticks++; wakeup(&ticks); @@ -74,38 +74,38 @@ trap(struct trapframe *tf) case T_IRQ0 + 7: case T_IRQ0 + IRQ_SPURIOUS: cprintf("cpu%d: spurious interrupt at %x:%x\n", - cpunum(), tf->cs, tf->eip); + cpuid(), tf->cs, tf->eip); lapiceoi(); break; //PAGEBREAK: 13 default: - if(proc == 0 || (tf->cs&3) == 0){ + if(myproc() == 0 || (tf->cs&3) == 0){ // In kernel, it must be our mistake. cprintf("unexpected trap %d from cpu %d eip %x (cr2=0x%x)\n", - tf->trapno, cpunum(), tf->eip, rcr2()); + tf->trapno, cpuid(), tf->eip, rcr2()); panic("trap"); } // In user space, assume process misbehaved. cprintf("pid %d %s: trap %d err %d on cpu %d " "eip 0x%x addr 0x%x--kill proc\n", - proc->pid, proc->name, tf->trapno, tf->err, cpunum(), tf->eip, + myproc()->pid, myproc()->name, tf->trapno, tf->err, cpuid(), tf->eip, rcr2()); - proc->killed = 1; + myproc()->killed = 1; } // 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(proc && proc->killed && (tf->cs&3) == DPL_USER) + if(myproc() && myproc()->killed && (tf->cs&3) == DPL_USER) exit(); // Force process to give up CPU on clock tick. // If interrupts were on while locks held, would need to check nlock. - if(proc && proc->state == RUNNING && tf->trapno == T_IRQ0+IRQ_TIMER) + if(myproc() && myproc()->state == RUNNING && tf->trapno == T_IRQ0+IRQ_TIMER) yield(); // Check if the process has been killed since we yielded - if(proc && proc->killed && (tf->cs&3) == DPL_USER) + if(myproc() && myproc()->killed && (tf->cs&3) == DPL_USER) exit(); } |