X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Kernel%2Farch%2Fx86%2Fproc.c;h=d468d11a215f3b64aaeb40d7f50cf2a19586219e;hb=3688167daa33f39c82d30563f7dae7ef57f57072;hp=448eab27d4ba4d67613f4ea76fa4c81ff8179df8;hpb=35e419b3110ef56ffdc3f16c1fc819874b888ba5;p=tpg%2Facess2.git diff --git a/Kernel/arch/x86/proc.c b/Kernel/arch/x86/proc.c index 448eab27..d468d11a 100644 --- a/Kernel/arch/x86/proc.c +++ b/Kernel/arch/x86/proc.c @@ -24,10 +24,12 @@ extern int giNumCPUs; extern int giNextTID; extern int giTotalTickets; extern int giNumActiveThreads; +extern tThread gThreadZero; extern tThread *gActiveThreads; extern tThread *gSleepingThreads; extern tThread *gDeleteThreads; extern tThread *Threads_GetNextToRun(int CPU); +extern void Threads_Dump(); // === PROTOTYPES === void ArchThreads_Init(); @@ -39,7 +41,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 +126,20 @@ void ArchThreads_Init() } #endif + #if USE_MP + gCurrentThread[0] = &gThreadZero; + #else + gCurrentThread = &gThreadZero; + #endif + + #if USE_PAE + gThreadZero.MemState.PDP[0] = 0; + gThreadZero.MemState.PDP[1] = 0; + gThreadZero.MemState.PDP[2] = 0; + #else + gThreadZero.MemState.CR3 = (Uint)gaInitPageDir - KERNEL_BASE; + #endif + // Set timer frequency outb(0x43, 0x34); // Set Channel 0, Low/High, Rate Generator outb(0x40, TIMER_DIVISOR&0xFF); // Low Byte of Divisor @@ -134,7 +150,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"); } @@ -290,6 +313,8 @@ int Proc_Clone(Uint *Err, Uint Flags) giTotalTickets += newThread->NumTickets; RELEASE( &giThreadListLock ); + Threads_Dump(); + return newThread->TID; } @@ -442,7 +467,7 @@ void Proc_Scheduler(int CPU) // Check if there is any tasks running if(giNumActiveThreads == 0) { - Log("No Active threads, sleeping\n"); + Log("No Active threads, sleeping"); __asm__ __volatile__ ("hlt"); return; }