From: John Hodge Date: Tue, 24 Aug 2010 02:36:49 +0000 (+0800) Subject: Fixed TID0 not being on the All Threads list X-Git-Tag: rel0.06~44 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=3b0cee8ca739fc5c564c78467fdc65c4d83d45a1;p=tpg%2Facess2.git Fixed TID0 not being on the All Threads list - Also stopped VM8086 from busy polling --- diff --git a/Kernel/arch/x86/mm_virt.c b/Kernel/arch/x86/mm_virt.c index fdc19b14..3c893f8e 100644 --- a/Kernel/arch/x86/mm_virt.c +++ b/Kernel/arch/x86/mm_virt.c @@ -919,7 +919,7 @@ tVAddr MM_MapTemp(tPAddr PAddr) return TEMP_MAP_ADDR + (i << 12); } Mutex_Release( &glTempMappings ); - Threads_Yield(); // TODO: Less expensive + Threads_Yield(); // TODO: Use a sleep queue here instead } } diff --git a/Kernel/arch/x86/vm8086.c b/Kernel/arch/x86/vm8086.c index 5253a62d..469ab436 100644 --- a/Kernel/arch/x86/vm8086.c +++ b/Kernel/arch/x86/vm8086.c @@ -153,6 +153,7 @@ void VM8086_GPF(tRegs *Regs) //Log_Log("VM8086", "gpVM8086_State = %p, gVM8086_CallingThread = %i", // gpVM8086_State, gVM8086_CallingThread); if( gpVM8086_State ) { + int ret; gpVM8086_State->AX = Regs->eax; gpVM8086_State->CX = Regs->ecx; gpVM8086_State->DX = Regs->edx; gpVM8086_State->BX = Regs->ebx; gpVM8086_State->BP = Regs->ebp; @@ -160,8 +161,9 @@ void VM8086_GPF(tRegs *Regs) gpVM8086_State->DS = Regs->ds; gpVM8086_State->ES = Regs->es; gpVM8086_State = NULL; // Ensure the caller wakes - //while(Threads_WakeTID(gVM8086_CallingThread) == -EALREADY) - // Threads_Yield(); + while( (ret = Threads_WakeTID(gVM8086_CallingThread)) == -EALREADY) { + Threads_Yield(); + } } //Log_Log("VM8086", "Waiting for something to do"); @@ -406,8 +408,8 @@ void VM8086_Int(tVM8086 *State, Uint8 Interrupt) gpVM8086_State = State; gVM8086_CallingThread = Threads_GetTID(); Threads_WakeTID( gVM8086_WorkerPID ); - while( gpVM8086_State != NULL ) - Threads_Yield(); + Threads_Sleep(); + while( gpVM8086_State != NULL ) Threads_Sleep(); Mutex_Release( &glVM8086_Process ); } diff --git a/Kernel/threads.c b/Kernel/threads.c index 610f7b5d..9fd052b6 100644 --- a/Kernel/threads.c +++ b/Kernel/threads.c @@ -90,6 +90,7 @@ void Threads_Init(void) // Create Initial Task gActiveThreads = &gThreadZero; + gAllThreads = &gThreadZero; //giFreeTickets = gThreadZero.NumTickets; giNumActiveThreads = 1; @@ -313,6 +314,8 @@ tThread *Threads_GetThread(Uint TID) if(thread->TID == TID) return thread; } + + Log("Unable to find TID %i on main list\n", TID); return NULL; }