X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=KernelLand%2FKernel%2Fthreads.c;h=9f76070371cc7755a5f9e3cba849c051e1ac697c;hb=e2277feaba2d0e354d6d9e4e737b2feb45b0106d;hp=67a2f637462e5b86252c40978b9cecee18cb21de;hpb=75c6f0e9aa83ccc662620071eec8bff0a81aa3ef;p=tpg%2Facess2.git diff --git a/KernelLand/Kernel/threads.c b/KernelLand/Kernel/threads.c index 67a2f637..9f760703 100644 --- a/KernelLand/Kernel/threads.c +++ b/KernelLand/Kernel/threads.c @@ -732,6 +732,39 @@ void Threads_int_WaitForStatusEnd(enum eThreadStatus Status) } } +void Threads_int_Sleep(enum eThreadStatus Status, void *Ptr, int Num, tThread **ListHead, tThread **ListTail, tShortSpinlock *Lock) +{ + SHORTLOCK( &glThreadListLock ); + tThread *us = Threads_RemActive(); + us->Next = NULL; + // - Mark as sleeping + us->Status = Status; + us->WaitPointer = Ptr; + us->RetStatus = Num; // Use RetStatus as a temp variable + + // - Add to waiting + if( ListTail ) { + if(*ListTail) { + (*ListTail)->Next = us; + *ListTail = us; + } + else { + *ListHead = us; + *ListTail = us; + } + } + else { + *ListHead = us; + } + + //if( Proc_ThreadSync(us) ) + // return ; + SHORTREL( &glThreadListLock ); + if( Lock ) + SHORTLOCK( Lock ); + Threads_int_WaitForStatusEnd(Status); +} + /** * \fn void Threads_Sleep(void) * \brief Take the current process off the run queue