X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=KernelLand%2FKernel%2Fthreads.c;h=7dd9f6e929cb2cd0c13a8ac154ec623573df2605;hb=6b29d7427e7d1ad73f0a0d0ae771bd25da7b7f1a;hp=a86eba07fc5e9e07703c0eeac41096aa7b154aec;hpb=b0da731b2d89b9dd58de2c98eaf6218a41a21920;p=tpg%2Facess2.git diff --git a/KernelLand/Kernel/threads.c b/KernelLand/Kernel/threads.c index a86eba07..7dd9f6e9 100644 --- a/KernelLand/Kernel/threads.c +++ b/KernelLand/Kernel/threads.c @@ -712,6 +712,22 @@ void Threads_Yield(void) Proc_Reschedule(); } +/** + * \breif Wait for the thread status to not be a specified value + */ +void Threads_int_WaitForStatusEnd(enum eThreadStatus Status) +{ + tThread *us = Proc_GetCurThread(); + ASSERT(Status != THREAD_STAT_ACTIVE); + ASSERT(Status != THREAD_STAT_DEAD); + while( us->Status == Status ) + { + Proc_Reschedule(); + if( us->Status == Status ) + Debug("Thread %p(%i %s) rescheduled while in %s state", casTHREAD_STAT[Status]); + } +} + /** * \fn void Threads_Sleep(void) * \brief Take the current process off the run queue @@ -743,12 +759,7 @@ void Threads_Sleep(void) // Release Spinlock SHORTREL( &glThreadListLock ); - - while(cur->Status != THREAD_STAT_ACTIVE) { - Proc_Reschedule(); - if( cur->Status != THREAD_STAT_ACTIVE ) - Log("%i - Huh? why am I up? zzzz...", cur->TID); - } + Threads_int_WaitForStatusEnd(THREAD_STAT_SLEEPING); }