char *Threads_GetName(tTID ID);
#if 0
void Threads_SetPriority(tThread *Thread, int Pri);
-tThread *Threads_CloneTCB(Uint *Err, Uint Flags);
+tThread *Threads_CloneTCB(Uint Flags);
int Threads_WaitTID(int TID, int *status);
tThread *Threads_GetThread(Uint TID);
#endif
void Threads_Exit(int TID, int Status);
void Threads_Kill(tThread *Thread, int Status);
void Threads_Yield(void);
-#endif
-void Threads_int_Sleep(enum eThreadStatus Status, void *Ptr, int Num, tThread **ListHead, tThread **ListTail, tShortSpinlock *Lock);
-#if 0
+ int Threads_int_Sleep(enum eThreadStatus Status, void *Ptr, int Num, tThread **ListHead, tThread **ListTail, tShortSpinlock *Lock);
void Threads_Sleep(void);
int Threads_Wake(tThread *Thread);
void Threads_AddActive(tThread *Thread);
// Specific Thread
if(TID > 0)
{
+ // TODO: Register on thread to be poked when it dies
tTID ret;
// NOTE: Race condition - Other child dies, desired child dies, first death is 'lost'
while( (ret = Threads_WaitTID(-1, Status)) != TID )
}
}
-void Threads_int_Sleep(enum eThreadStatus Status, void *Ptr, int Num, tThread **ListHead, tThread **ListTail, tShortSpinlock *Lock)
+int Threads_int_Sleep(enum eThreadStatus Status, void *Ptr, int Num, tThread **ListHead, tThread **ListTail, tShortSpinlock *Lock)
{
SHORTLOCK( &glThreadListLock );
tThread *us = Threads_RemActive();
if( ListTail ) {
if(*ListTail) {
(*ListTail)->Next = us;
- *ListTail = us;
}
else {
*ListHead = us;
- *ListTail = us;
}
+ *ListTail = us;
}
else {
*ListHead = us;
// return ;
SHORTREL( &glThreadListLock );
if( Lock )
- SHORTLOCK( Lock );
+ SHORTREL( Lock );
Threads_int_WaitForStatusEnd(Status);
+ us->WaitPointer = NULL;
+ return us->RetStatus;
}
/**
);
break;
case THREAD_STAT_EVENTSLEEP:
- // TODO: Event mask
+ Log(" Event Mask: %x", thread->RetStatus);
break;
case THREAD_STAT_ZOMBIE:
Log(" Return Status: %i", thread->RetStatus);