From: John Hodge Date: Fri, 25 Sep 2009 02:37:03 +0000 (+0800) Subject: Fix race condition with scheduler starting before task list is populated X-Git-Tag: rel0.06~522 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=0259a3c08b2c7d5c9d05bd0d051a67399e755638;p=tpg%2Facess2.git Fix race condition with scheduler starting before task list is populated --- diff --git a/Kernel/arch/x86/proc.c b/Kernel/arch/x86/proc.c index 48a3c1a0..2413a6e2 100644 --- a/Kernel/arch/x86/proc.c +++ b/Kernel/arch/x86/proc.c @@ -40,7 +40,7 @@ void Proc_Scheduler(); // === GLOBALS === // --- Current State --- #if USE_MP -tThread *gCurrentThread[MAX_CPUS] = NULL; +tThread *gCurrentThread[MAX_CPUS] = {NULL}; #else tThread *gCurrentThread = NULL; #endif @@ -141,7 +141,14 @@ void ArchThreads_Init() // Change Stacks Proc_ChangeStack(); - +} + +/** + * \fn void Proc_Start() + * \brief Start process scheduler + */ +void Proc_Start() +{ // Start Interrupts (and hence scheduler) __asm__ __volatile__("sti"); } diff --git a/Kernel/threads.c b/Kernel/threads.c index 27356613..1644b504 100644 --- a/Kernel/threads.c +++ b/Kernel/threads.c @@ -13,6 +13,7 @@ // === IMPORTS === extern void ArchThreads_Init(); +extern void Proc_Start(); extern tThread *Proc_GetCurThread(); extern int Proc_Clone(Uint *Err, Uint Flags); @@ -94,6 +95,8 @@ void Threads_Init() for(;;) __asm__ __volatile__ ("hlt"); // Just yeilds } #endif + + Proc_Start(); } /**