From 19333efb9eb634f17bea41d0cec8ee28c595cce8 Mon Sep 17 00:00:00 2001 From: rsc Date: Sun, 31 May 2009 00:28:45 +0000 Subject: Some proc cleanup, moving some of copyproc into allocproc. Also, an experiment: use "thread-local" storage for c and cp instead of the #define macro for curproc[cpu()]. --- main.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index f4914db..18e1790 100644 --- a/main.c +++ b/main.c @@ -5,6 +5,9 @@ #include "proc.h" #include "x86.h" +__thread struct cpu *c; +__thread struct proc *cp; + static void bootothers(void); static void mpmain(void) __attribute__((noreturn)); @@ -14,20 +17,22 @@ main(void) { mpinit(); // collect info about this machine lapicinit(mpbcpu()); + ksegment(); + picinit(); // interrupt controller + ioapicinit(); // another interrupt controller + consoleinit(); // I/O devices & their interrupts + uartinit(); // serial port cprintf("\ncpu%d: starting xv6\n\n", cpu()); - pinit(); // process table - binit(); // buffer cache - picinit(); // interrupt controller - ioapicinit(); // another interrupt controller kinit(); // physical memory allocator + pinit(); // process table tvinit(); // trap vectors + binit(); // buffer cache fileinit(); // file table iinit(); // inode cache - consoleinit(); // I/O devices & their interrupts - ideinit(); // disk + ideinit(); // disk if(!ismp) - timerinit(); // uniprocessor timer + timerinit(); // uniprocessor timer userinit(); // first user process bootothers(); // start other processors @@ -40,12 +45,12 @@ main(void) static void mpmain(void) { - cprintf("cpu%d: mpmain\n", cpu()); - idtinit(); if(cpu() != mpbcpu()) lapicinit(cpu()); - setupsegs(0); - xchg(&cpus[cpu()].booted, 1); + ksegment(); + cprintf("cpu%d: mpmain\n", cpu()); + idtinit(); + xchg(&c->booted, 1); cprintf("cpu%d: scheduling\n", cpu()); scheduler(); -- cgit v1.2.3