X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Kernel%2Fthreads.c;h=3be978928545eb90c14263daaedb788b5d70ae21;hb=b6c3b3cf61caafbd91bbf3acc81995e472656a5b;hp=5f2e3d7fc0354cde3b736d66c53dc23e39fc11b1;hpb=9d3800f60f2212432e550a4e003ae65b498a4d36;p=tpg%2Facess2.git diff --git a/Kernel/threads.c b/Kernel/threads.c index 5f2e3d7f..3be97892 100644 --- a/Kernel/threads.c +++ b/Kernel/threads.c @@ -265,7 +265,12 @@ int Threads_WaitTID(int TID, int *status) tThread *t = Threads_GetThread(TID); int initStatus = t->Status; int ret; - while(t->Status == initStatus) Threads_Yield(); + + if(initStatus != THREAD_STAT_ZOMBIE) + while(t->Status == initStatus) { + Threads_Yield(); + } + ret = t->RetStatus; switch(t->Status) { @@ -362,6 +367,7 @@ void Threads_Exit(int TID, int Status) Threads_Kill( Proc_GetCurThread(), (Uint)Status & 0xFF ); else Threads_Kill( Threads_GetThread(TID), (Uint)Status & 0xFF ); + for(;;) HALT(); // Just in case } /** @@ -433,6 +439,9 @@ void Threads_Kill(tThread *Thread, int Status) // Release spinlocks RELEASE( &Thread->IsLocked ); // Released first so that it IS released RELEASE( &giThreadListLock ); + + //Log("Thread %i went *hurk*", Thread->TID); + if(Status != -1) HALT(); } @@ -463,7 +472,8 @@ void Threads_Sleep() // Get thread before current thread thread = Threads_int_GetPrev( &gActiveThreads, cur ); if(!thread) { - Warning("Proc_Sleep - Current thread is not on the active queue"); + Warning("Threads_Sleep - Current thread is not on the active queue"); + Threads_Dump(); return; } @@ -493,11 +503,11 @@ void Threads_Sleep() // Release Spinlock RELEASE( &giThreadListLock ); - HALT(); + while(cur->Status != THREAD_STAT_ACTIVE) HALT(); } -/**c0108919: +/** * \fn void Threads_Wake( tThread *Thread ) * \brief Wakes a sleeping/waiting thread up */ @@ -621,18 +631,23 @@ int Threads_GetGID() void Threads_Dump() { tThread *thread; + tThread *cur = Proc_GetCurThread(); Log("Active Threads:"); for(thread=gActiveThreads;thread;thread=thread->Next) { - Log(" %i (%i) - %s", thread->TID, thread->TGID, thread->ThreadName); + Log("%c%i (%i) - %s", + (thread==cur?'*':' '), + thread->TID, thread->TGID, thread->ThreadName); Log(" %i Tickets, Quantum %i", thread->NumTickets, thread->Quantum); Log(" KStack 0x%x", thread->KernelStack); } Log("Sleeping Threads:"); for(thread=gSleepingThreads;thread;thread=thread->Next) { - Log(" %i (%i) - %s", thread->TID, thread->TGID, thread->ThreadName); + Log("%c%i (%i) - %s", + (thread==cur?'*':' '), + thread->TID, thread->TGID, thread->ThreadName); Log(" %i Tickets, Quantum %i", thread->NumTickets, thread->Quantum); Log(" KStack 0x%x", thread->KernelStack); } @@ -689,6 +704,6 @@ tThread *Threads_GetNextToRun(int CPU) void Threads_SegFault(tVAddr Addr) { //Threads_SendSignal( Proc_GetCurThread()->TID, SIGSEGV ); - Log("Thread #%i committed a segfault at address %p\n", Proc_GetCurThread()->TID, Addr); - Threads_Exit( 0, 0 ); + Warning("Thread #%i committed a segfault at address %p", Proc_GetCurThread()->TID, Addr); + Threads_Exit( 0, -1 ); }