X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Tools%2Fnativelib%2Fthreads_int.c;h=b2ad9f661667835a6359bb9157772f35d054baaa;hb=d1e3e105c7605d0c9f02dd7e2f3b1377ea61aea4;hp=3b7b08a479178729fb567f2da56867ade2167a7d;hpb=083c31409b9f25c96807ab8fef8ac79e8fe4cf9e;p=tpg%2Facess2.git diff --git a/Tools/nativelib/threads_int.c b/Tools/nativelib/threads_int.c index 3b7b08a4..b2ad9f66 100644 --- a/Tools/nativelib/threads_int.c +++ b/Tools/nativelib/threads_int.c @@ -8,13 +8,13 @@ #include #include #include +#include // printf debugging #include #include #include #include // === TYPES === -typedef struct sThread tThread; struct sThreadIntMutex { int lock; }; struct sThreadIntSem { int val; }; @@ -91,9 +91,9 @@ tThreadIntSem *Threads_int_SemCreate(void) void Threads_int_SemSignal(tThreadIntSem *Sem) { - if( sem_wait ) + if( sem_post ) { - sem_wait( (void*)Sem ); + sem_post( (void*)Sem ); } else { @@ -103,9 +103,12 @@ void Threads_int_SemSignal(tThreadIntSem *Sem) void Threads_int_SemWaitAll(tThreadIntSem *Sem) { - if( sem_post ) + if( sem_wait ) { - sem_post( (void*)Sem ); + // TODO: Handle multiples + sem_wait( (void*)Sem ); + while( sem_trywait((void*)Sem) ) + ; } else { @@ -152,7 +155,9 @@ void SHORTLOCK(tShortSpinlock *Lock) *Lock = malloc(sizeof(pthread_mutex_t)); pthread_mutex_init(*Lock, NULL); } +// printf("%p: SHORTLOCK wait\n", lpThreads_This); pthread_mutex_lock(*Lock); +// printf("%p: SHORTLOCK held %p\n", lpThreads_This, __builtin_return_address(0)); } } @@ -166,6 +171,7 @@ void SHORTREL(tShortSpinlock *Lock) else { pthread_mutex_unlock(*Lock); +// printf("%p: SHORTLOCK rel\n", lpThreads_This); } }