summaryrefslogtreecommitdiff
path: root/proc.c
diff options
context:
space:
mode:
authorRobert Morris <[email protected]>2010-08-06 11:12:18 -0400
committerRobert Morris <[email protected]>2010-08-06 11:12:18 -0400
commitc4cc10da7ef6d65f0f654445e0af35b8309f16c2 (patch)
tree771c4791115f945fc86ea9eadc350bb22c518535 /proc.c
parent1afc9d3fcaa7c5992659bb8b69f639b746dda2bc (diff)
downloadxv6-labs-c4cc10da7ef6d65f0f654445e0af35b8309f16c2.tar.gz
xv6-labs-c4cc10da7ef6d65f0f654445e0af35b8309f16c2.tar.bz2
xv6-labs-c4cc10da7ef6d65f0f654445e0af35b8309f16c2.zip
fix corner cases in exec of ELF
put an invalid page below the stack have fork() handle invalid pages
Diffstat (limited to 'proc.c')
-rw-r--r--proc.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/proc.c b/proc.c
index dd6f27e..f799a4d 100644
--- a/proc.c
+++ b/proc.c
@@ -145,7 +145,7 @@ growproc(int n)
if (!allocuvm(proc->pgdir, (char *)proc->sz, n))
return -1;
proc->sz += n;
- loadvm(proc);
+ switchuvm(proc);
return 0;
}
@@ -214,9 +214,10 @@ scheduler(void)
// to release ptable.lock and then reacquire it
// before jumping back to us.
proc = p;
- loadvm(p);
+ switchuvm(p);
p->state = RUNNING;
swtch(&cpu->scheduler, proc->context);
+ switchkvm();
// Process is done running for now.
// It should have changed its p->state before coming back.
@@ -242,7 +243,6 @@ sched(void)
panic("sched running");
if(readeflags()&FL_IF)
panic("sched interruptible");
- lcr3(PADDR(kpgdir)); // Switch to the kernel page table
intena = cpu->intena;
swtch(&proc->context, cpu->scheduler);
cpu->intena = intena;
@@ -414,8 +414,8 @@ wait(void)
// Found one.
pid = p->pid;
kfree(p->kstack, KSTACKSIZE);
- p->kstack = 0;
- freevm(p->pgdir);
+ p->kstack = 0;
+ freevm(p->pgdir);
p->state = UNUSED;
p->pid = 0;
p->parent = 0;