From 0259a3c08b2c7d5c9d05bd0d051a67399e755638 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Fri, 25 Sep 2009 10:37:03 +0800 Subject: [PATCH 1/1] Fix race condition with scheduler starting before task list is populated --- Kernel/arch/x86/proc.c | 11 +++++++++-- Kernel/threads.c | 3 +++ 2 files changed, 12 insertions(+), 2 deletions(-) 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(); } /** -- 2.20.1