summaryrefslogtreecommitdiff
path: root/trap.c
diff options
context:
space:
mode:
Diffstat (limited to 'trap.c')
-rw-r--r--trap.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/trap.c b/trap.c
index 651a9d6..446ebaa 100644
--- a/trap.c
+++ b/trap.c
@@ -36,18 +36,18 @@ void
trap(struct trapframe *tf)
{
if(tf->trapno == T_SYSCALL){
- if(cp->killed)
+ if(proc->killed)
exit();
- cp->tf = tf;
+ proc->tf = tf;
syscall();
- if(cp->killed)
+ if(proc->killed)
exit();
return;
}
switch(tf->trapno){
case T_IRQ0 + IRQ_TIMER:
- if(cpu() == 0){
+ if(cpu->id == 0){
acquire(&tickslock);
ticks++;
wakeup(&ticks);
@@ -70,35 +70,35 @@ trap(struct trapframe *tf)
case T_IRQ0 + 7:
case T_IRQ0 + IRQ_SPURIOUS:
cprintf("cpu%d: spurious interrupt at %x:%x\n",
- cpu(), tf->cs, tf->eip);
+ cpu->id, tf->cs, tf->eip);
lapiceoi();
break;
default:
- if(cp == 0 || (tf->cs&3) == 0){
+ if(proc == 0 || (tf->cs&3) == 0){
// In kernel, it must be our mistake.
cprintf("unexpected trap %d from cpu %d eip %x\n",
- tf->trapno, cpu(), tf->eip);
+ tf->trapno, cpu->id, tf->eip);
panic("trap");
}
// In user space, assume process misbehaved.
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;
+ proc->pid, proc->name, tf->trapno, tf->err, cpu->id, tf->eip);
+ proc->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(cp && cp->killed && (tf->cs&3) == DPL_USER)
+ if(proc && proc->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(cp && cp->state == RUNNING && tf->trapno == T_IRQ0+IRQ_TIMER)
+ if(proc && proc->state == RUNNING && tf->trapno == T_IRQ0+IRQ_TIMER)
yield();
// Check if the process has been killed since we yielded
- if(cp && cp->killed && (tf->cs&3) == DPL_USER)
+ if(proc && proc->killed && (tf->cs&3) == DPL_USER)
exit();
}