git.ucc.asn.au
/
tpg
/
acess2.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
7143c19
)
Tools/nativelib - Threading fixes
author
John Hodge
<
[email protected]
>
Fri, 8 Feb 2013 10:50:54 +0000
(18:50 +0800)
committer
John Hodge
<
[email protected]
>
Fri, 8 Feb 2013 10:50:54 +0000
(18:50 +0800)
Tools/nativelib/include/pthread_weak.h
patch
|
blob
|
history
Tools/nativelib/threads.c
patch
|
blob
|
history
Tools/nativelib/threads_int.c
patch
|
blob
|
history
Tools/nativelib/time.c
patch
|
blob
|
history
diff --git
a/Tools/nativelib/include/pthread_weak.h
b/Tools/nativelib/include/pthread_weak.h
index
30ac250
..
ccc4002
100644
(file)
--- a/
Tools/nativelib/include/pthread_weak.h
+++ b/
Tools/nativelib/include/pthread_weak.h
@@
-18,6
+18,7
@@
extern int pthread_mutex_destroy (pthread_mutex_t*) __attribute__ ((weak));
extern int sem_init(sem_t *sem, int pshared, unsigned int value) __attribute__ ((weak));
extern int sem_wait(sem_t *sem) __attribute__ ((weak));
extern int sem_init(sem_t *sem, int pshared, unsigned int value) __attribute__ ((weak));
extern int sem_wait(sem_t *sem) __attribute__ ((weak));
+extern int sem_trywait(sem_t *sem) __attribute__ ((weak));
extern int sem_post(sem_t *sem) __attribute__ ((weak));
extern int sem_getvalue(sem_t *sem, int *sval) __attribute__ ((weak));
extern int sem_post(sem_t *sem) __attribute__ ((weak));
extern int sem_getvalue(sem_t *sem, int *sval) __attribute__ ((weak));
diff --git
a/Tools/nativelib/threads.c
b/Tools/nativelib/threads.c
index
b698770
..
aec7076
100644
(file)
--- a/
Tools/nativelib/threads.c
+++ b/
Tools/nativelib/threads.c
@@
-23,6
+23,7
@@
tShortSpinlock glThreadListLock;
void Threads_int_Init(void)
{
lpThreads_This = Threads_int_CreateTCB(NULL);
void Threads_int_Init(void)
{
lpThreads_This = Threads_int_CreateTCB(NULL);
+ Threads_SetName("ThreadZero");
}
tThread *Proc_GetCurThread(void)
}
tThread *Proc_GetCurThread(void)
diff --git
a/Tools/nativelib/threads_int.c
b/Tools/nativelib/threads_int.c
index
324b952
..
b2ad9f6
100644
(file)
--- a/
Tools/nativelib/threads_int.c
+++ b/
Tools/nativelib/threads_int.c
@@
-8,6
+8,7
@@
#include <stddef.h>
#include <stdlib.h>
#include <stdint.h>
#include <stddef.h>
#include <stdlib.h>
#include <stdint.h>
+#include <stdio.h> // printf debugging
#include <acess_logging.h>
#include <threads_int.h>
#include <pthread_weak.h>
#include <acess_logging.h>
#include <threads_int.h>
#include <pthread_weak.h>
@@
-90,9
+91,9
@@
tThreadIntSem *Threads_int_SemCreate(void)
void Threads_int_SemSignal(tThreadIntSem *Sem)
{
void Threads_int_SemSignal(tThreadIntSem *Sem)
{
- if( sem_
wai
t )
+ if( sem_
pos
t )
{
{
- sem_
wai
t( (void*)Sem );
+ sem_
pos
t( (void*)Sem );
}
else
{
}
else
{
@@
-102,9
+103,12
@@
void Threads_int_SemSignal(tThreadIntSem *Sem)
void Threads_int_SemWaitAll(tThreadIntSem *Sem)
{
void Threads_int_SemWaitAll(tThreadIntSem *Sem)
{
- if( sem_
pos
t )
+ if( sem_
wai
t )
{
{
- sem_post( (void*)Sem );
+ // TODO: Handle multiples
+ sem_wait( (void*)Sem );
+ while( sem_trywait((void*)Sem) )
+ ;
}
else
{
}
else
{
@@
-151,7
+155,9
@@
void SHORTLOCK(tShortSpinlock *Lock)
*Lock = malloc(sizeof(pthread_mutex_t));
pthread_mutex_init(*Lock, NULL);
}
*Lock = malloc(sizeof(pthread_mutex_t));
pthread_mutex_init(*Lock, NULL);
}
+// printf("%p: SHORTLOCK wait\n", lpThreads_This);
pthread_mutex_lock(*Lock);
pthread_mutex_lock(*Lock);
+// printf("%p: SHORTLOCK held %p\n", lpThreads_This, __builtin_return_address(0));
}
}
}
}
@@
-165,6
+171,7
@@
void SHORTREL(tShortSpinlock *Lock)
else
{
pthread_mutex_unlock(*Lock);
else
{
pthread_mutex_unlock(*Lock);
+// printf("%p: SHORTLOCK rel\n", lpThreads_This);
}
}
}
}
diff --git
a/Tools/nativelib/time.c
b/Tools/nativelib/time.c
index
4eb7463
..
f2f18d8
100644
(file)
--- a/
Tools/nativelib/time.c
+++ b/
Tools/nativelib/time.c
@@
-19,6
+19,7
@@
void Time_ScheduleTimer(tTimer *Timer, int Delta)
if( !Timer )
{
// SIGALRM
if( !Timer )
{
// SIGALRM
+ Log_Warning("Time", "TODO: Alarm event in %i ms", Delta);
}
else
{
}
else
{
UCC
git Repository :: git.ucc.asn.au