]> Devi Nivas Git - cs3210-lab0.git/commitdiff
Don't kill process when inside kernel.
authorrsc <rsc>
Sun, 16 Jul 2006 02:09:45 +0000 (02:09 +0000)
committerrsc <rsc>
Sun, 16 Jul 2006 02:09:45 +0000 (02:09 +0000)
trap.c

diff --git a/trap.c b/trap.c
index 78a62f0ecda805b4e461ae290ec72159eb97bce3..4c8a4bdf5094b258176748a2a55f9a94975fac88 100644 (file)
--- a/trap.c
+++ b/trap.c
@@ -70,11 +70,18 @@ trap(struct Trapframe *tf)
     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){
-      if((read_eflags() & FL_IF) == 0)
-        panic("timer interrupt but interrupts now disabled");
-      if(cp->killed)
+      // Force process exit if it has been killed
+      // and the interrupt came from user space.
+      // (If the kernel was executing at time of interrupt,
+      // don't kill the process.  Let the process get back
+      // out to its regular system call return.)
+      if((tf->tf_cs&3) == 3 && cp->killed)
         proc_exit();
+      
+      // Force process to give up CPU and let others run.
       if(cp->state == RUNNING)
         yield();
     }