X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Kernel%2Fthreads.c;h=90eb740e49829d63bbc54ce81205856c674f92ba;hb=c2adb8d03edd3bcf25eb2fd9a90ed74200ca78fe;hp=dd7cfcd243f7e3f5ccfe87676d293e3069650988;hpb=d1f16adf5f2e94e836ea6658186a6ff6d94f54d8;p=tpg%2Facess2.git diff --git a/Kernel/threads.c b/Kernel/threads.c index dd7cfcd2..90eb740e 100644 --- a/Kernel/threads.c +++ b/Kernel/threads.c @@ -3,7 +3,7 @@ * threads.c * - Common Thread Control */ -#include +#include #include #include @@ -335,7 +335,7 @@ void Threads_AddToDelete(tThread *Thread) } /** - * \fn tThread *Threads_int_GetPrev(tThread *List, tThread *Thread) + * \fn tThread *Threads_int_GetPrev(tThread **List, tThread *Thread) * \brief Gets the previous entry in a thead linked list */ tThread *Threads_int_GetPrev(tThread **List, tThread *Thread) @@ -373,7 +373,8 @@ void Threads_Exit(int TID, int Status) /** * \fn void Threads_Kill(tThread *Thread, int Status) * \brief Kill a thread - * \param TID Thread ID (0 for current) + * \param Thread Thread to kill + * \param Status Status code to return to the parent */ void Threads_Kill(tThread *Thread, int Status) { @@ -464,7 +465,7 @@ void Threads_Sleep() tThread *cur = Proc_GetCurThread(); tThread *thread; - //Log("Proc_Sleep: %i going to sleep", cur->TID); + Log("Proc_Sleep: %i going to sleep", cur->TID); // Acquire Spinlock LOCK( &giThreadListLock ); @@ -472,7 +473,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; } @@ -502,11 +504,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 */ @@ -630,18 +632,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); } @@ -701,3 +708,6 @@ void Threads_SegFault(tVAddr Addr) Warning("Thread #%i committed a segfault at address %p", Proc_GetCurThread()->TID, Addr); Threads_Exit( 0, -1 ); } + +// === EXPORTS === +EXPORT(Threads_GetUID);