diff options
author | rsc <rsc> | 2007-09-27 20:29:50 +0000 |
---|---|---|
committer | rsc <rsc> | 2007-09-27 20:29:50 +0000 |
commit | ce2e7515552adca3a60e349de2931112736d17bf (patch) | |
tree | 4398d7aee836b939db83afa1f0c9f8e6bb1afb1f /main.c | |
parent | aefc13f8ba13475fa721d6da837db5e368ee1b0a (diff) | |
download | xv6-labs-ce2e7515552adca3a60e349de2931112736d17bf.tar.gz xv6-labs-ce2e7515552adca3a60e349de2931112736d17bf.tar.bz2 xv6-labs-ce2e7515552adca3a60e349de2931112736d17bf.zip |
test: store curproc at top of stack
I don't actually think this is worthwhile, but I figured
I would check it in before reverting it, so that it can
be in the revision history.
Pros:
* curproc doesn't need to turn on/off interrupts
* scheduler doesn't have to edit curproc anymore
Cons:
* it's ugly
* all the stack computation is more complicated.
* it doesn't actually simplify anything but curproc,
and even curproc is harder to follow.
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -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); |