summaryrefslogtreecommitdiff
path: root/trap.c
diff options
context:
space:
mode:
authorrsc <rsc>2006-07-16 02:09:45 +0000
committerrsc <rsc>2006-07-16 02:09:45 +0000
commit72fef4f85513d200ca6b986b0bcc5c608142a1d6 (patch)
tree1a1609ac10ab450885a2556044c8081467ba8263 /trap.c
parent4ed974f5ea8cbb6ee296782d94d83d8edbc92026 (diff)
downloadxv6-labs-72fef4f85513d200ca6b986b0bcc5c608142a1d6.tar.gz
xv6-labs-72fef4f85513d200ca6b986b0bcc5c608142a1d6.tar.bz2
xv6-labs-72fef4f85513d200ca6b986b0bcc5c608142a1d6.zip
Don't kill process when inside kernel.
Diffstat (limited to 'trap.c')
-rw-r--r--trap.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/trap.c b/trap.c
index 78a62f0..4c8a4bd 100644
--- 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();
}