// === GLOBALS ===
tThread gThreadZero = {
- State: 1,
- ThreadName: "ThreadZero"
+ .State=1,
+ .ThreadName="ThreadZero"
};
tThread *gpThreads = &gThreadZero;
__thread tThread *gpCurrentThread = &gThreadZero;
us->Next = NULL;
us->State = 3;
+ // TODO: Locking
if(thread->WaitingThreadsEnd)
{
thread->WaitingThreadsEnd->Next = us;
}
while(thread->State != 0)
+ {
pause();
+ Log_Debug("Threads", "Huh?... state = %i", thread->State);
+ }
if(Status) *Status = thread->ExitStatus;
thread->WaitingThreads = thread->WaitingThreads->Next;
tThread *toWake;
// VFS_Handles_Cleanup();
+
+ gpCurrentThread->ExitStatus = Status;
#if 1
- // Wait for the thread to be waited upon
- while( gpCurrentThread->WaitingThreads == NULL )
- SDL_Delay(10);
+ if( gpCurrentThread->Parent )
+ {
+ // Wait for the thread to be waited upon
+ while( gpCurrentThread->WaitingThreads == NULL )
+ SDL_Delay(10);
+ }
#endif
while( (toWake = gpCurrentThread->WaitingThreads) )
{
+ Log_Debug("Threads", "Threads_Exit - Waking %p %i '%s'", toWake, toWake->TID, toWake->ThreadName);
+
Threads_Wake(toWake);
while(gpCurrentThread->WaitingThreads == toWake)
int Threads_Wake(tThread *Thread)
{
+ Thread->State = 0;
kill( Thread->KernelTID, SIGUSR1 );
return 0;
}