From: John Hodge Date: Fri, 25 Sep 2009 02:31:56 +0000 (+0800) Subject: Fix Segfault in ArchThreads_Init and added MAX_CPUS macro (x86 = 8 cpus) X-Git-Tag: rel0.06~523 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=b574da4b635c3c030757e0877e7a947c5b4a4871;p=tpg%2Facess2.git Fix Segfault in ArchThreads_Init and added MAX_CPUS macro (x86 = 8 cpus) --- diff --git a/Kernel/arch/x86/include/arch.h b/Kernel/arch/x86/include/arch.h index 0611c6c4..dd459c29 100644 --- a/Kernel/arch/x86/include/arch.h +++ b/Kernel/arch/x86/include/arch.h @@ -38,6 +38,12 @@ # error "Unknown architecture '" #ARCH "'" #endif +#if USE_MP +# define MAX_CPUS 8 +#else +# define MAX_CPUS 1 +#endif + // === MACROS === #define LOCK(lockptr) do {int v=1;\ while(v)__asm__ __volatile__("lock xchgl %%eax, (%%edi)":"=a"(v):"a"(1),"D"(lockptr));}while(0) diff --git a/Kernel/arch/x86/proc.c b/Kernel/arch/x86/proc.c index 448eab27..48a3c1a0 100644 --- a/Kernel/arch/x86/proc.c +++ b/Kernel/arch/x86/proc.c @@ -24,6 +24,7 @@ extern int giNumCPUs; extern int giNextTID; extern int giTotalTickets; extern int giNumActiveThreads; +extern tThread gThreadZero; extern tThread *gActiveThreads; extern tThread *gSleepingThreads; extern tThread *gDeleteThreads; @@ -39,7 +40,7 @@ void Proc_Scheduler(); // === GLOBALS === // --- Current State --- #if USE_MP -tThread **gCurrentThread = NULL; +tThread *gCurrentThread[MAX_CPUS] = NULL; #else tThread *gCurrentThread = NULL; #endif @@ -124,6 +125,12 @@ void ArchThreads_Init() } #endif + #if USE_MP + gCurrentThread[0] = &gThreadZero; + #else + gCurrentThread = &gThreadZero; + #endif + // Set timer frequency outb(0x43, 0x34); // Set Channel 0, Low/High, Rate Generator outb(0x40, TIMER_DIVISOR&0xFF); // Low Byte of Divisor