summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'main.c')
-rw-r--r--main.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/main.c b/main.c
index 464112b..0f1acc8 100644
--- a/main.c
+++ b/main.c
@@ -42,12 +42,14 @@ main(void)
userinit(); // first user process
// Allocate scheduler stacks and boot the other CPUs.
- for(i=0; i<ncpu; i++)
+ for(i=0; i<ncpu; i++){
cpus[i].stack = kalloc(KSTACKSIZE);
+ *(void**)(cpus[i].stack + KSTACKTOP) = 0;
+ }
bootothers();
// Switch to our scheduler stack and continue with mpmain.
- asm volatile("movl %0, %%esp" : : "r" (cpus[bcpu].stack+KSTACKSIZE));
+ asm volatile("movl %0, %%esp" : : "r" (cpus[bcpu].stack+KSTACKTOP));
mpmain();
}
@@ -84,7 +86,7 @@ bootothers(void)
continue;
// Fill in %esp, %eip and start code on cpu.
- *(void**)(code-4) = c->stack + KSTACKSIZE;
+ *(void**)(code-4) = c->stack + KSTACKTOP;
*(void**)(code-8) = mpmain;
lapic_startap(c->apicid, (uint)code);