git.ucc.asn.au
/
tpg
/
acess2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
BuildConf/host - Slight fix to allow scan-build for non 64-bit architectures
[tpg/acess2.git]
/
AcessNative
/
acesskernel_src
/
threads.c
diff --git
a/AcessNative/acesskernel_src/threads.c
b/AcessNative/acesskernel_src/threads.c
index
3465992
..
dc4d643
100644
(file)
--- a/
AcessNative/acesskernel_src/threads.c
+++ b/
AcessNative/acesskernel_src/threads.c
@@
-70,8
+70,8
@@
typedef struct sThread
// === GLOBALS ===
tThread gThreadZero = {
// === GLOBALS ===
tThread gThreadZero = {
-
State:
1,
-
ThreadName:
"ThreadZero"
+
.State=
1,
+
.ThreadName=
"ThreadZero"
};
tThread *gpThreads = &gThreadZero;
__thread tThread *gpCurrentThread = &gThreadZero;
};
tThread *gpThreads = &gThreadZero;
__thread tThread *gpCurrentThread = &gThreadZero;
@@
-207,6
+207,7
@@
int Threads_WaitTID(int TID, int *Status)
us->Next = NULL;
us->State = 3;
us->Next = NULL;
us->State = 3;
+ // TODO: Locking
if(thread->WaitingThreadsEnd)
{
thread->WaitingThreadsEnd->Next = us;
if(thread->WaitingThreadsEnd)
{
thread->WaitingThreadsEnd->Next = us;
@@
-219,7
+220,10
@@
int Threads_WaitTID(int TID, int *Status)
}
while(thread->State != 0)
}
while(thread->State != 0)
+ {
pause();
pause();
+ Log_Debug("Threads", "Huh?... state = %i", thread->State);
+ }
if(Status) *Status = thread->ExitStatus;
thread->WaitingThreads = thread->WaitingThreads->Next;
if(Status) *Status = thread->ExitStatus;
thread->WaitingThreads = thread->WaitingThreads->Next;
@@
-247,15
+251,22
@@
void Threads_Exit(int TID, int Status)
tThread *toWake;
// VFS_Handles_Cleanup();
tThread *toWake;
// VFS_Handles_Cleanup();
+
+ gpCurrentThread->ExitStatus = Status;
#if 1
#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) )
{
#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)
Threads_Wake(toWake);
while(gpCurrentThread->WaitingThreads == toWake)
@@
-265,6
+276,7
@@
void Threads_Exit(int TID, int Status)
int Threads_Wake(tThread *Thread)
{
int Threads_Wake(tThread *Thread)
{
+ Thread->State = 0;
kill( Thread->KernelTID, SIGUSR1 );
return 0;
}
kill( Thread->KernelTID, SIGUSR1 );
return 0;
}
UCC
git Repository :: git.ucc.asn.au