22 #ifndef _GOS_X_THREADS_H
23 #define _GOS_X_THREADS_H
25 #if GOS_NEED_X_THREADS
29 typedef short gSemcount;
30 typedef int gThreadreturn;
31 typedef int gThreadpriority;
33 #define GFX_THREAD_FUNCTION(fnName, param) gThreadreturn fnName(void *param)
34 #define GFX_THREAD_STACK(name, sz) gU8 name[(sz) & ~3];
35 #define gfxThreadReturn(retval) return retval
38 #define gDelayForever ((gDelay)-1)
39 #define gSemMaxCount 0x7FFF
40 #define gThreadpriorityLow 0
41 #define gThreadpriorityNormal 1
42 #define gThreadpriorityHigh 2
67 #define gfxMutexDestroy(pmutex)
73 #define gfxSemDestroy(psem)
81 #define gfxThreadClose(thread)
89 void gfxThreadExit(gThreadreturn ret);
gThreadreturn gfxThreadWait(gThread thread)
Wait for a thread to finish.
void gfxSemSignal(gSem *psem)
Signal a semaphore.
void * gThread
A thread handle.
gTicks gfxSystemTicks(void)
Get the current operating system tick time.
void gfxYield(void)
Yield the current thread.
#define GFX_THREAD_FUNCTION(fnName, param)
Declare a thread function.
void gfxMutexExit(gMutex *pmutex)
Exit the critical code region protected by the mutex.
gTicks gfxMillisecondsToTicks(gDelay ms)
Convert a given number of millseconds to a number of operating system ticks.
gBool gfxSemWait(gSem *psem, gDelay ms)
Wait on a semaphore.
void gfxSystemUnlock(void)
Unlock the operating system previous locked by gfxSystemLock()
void gfxSleepMicroseconds(gDelay us)
Put the current thread to sleep for the specified period in microseconds.
void gfxMutexEnter(gMutex *pmutex)
Enter the critical code region protected by the mutex.
gThread gfxThreadMe(void)
Get the current thread handle.
void gfxSystemLock(void)
Lock the operating system to protect a sequence of code.
void gfxMutexInit(gMutex *pmutex)
Initialise a mutex to protect a region of code from other threads.
gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, GFX_THREAD_FUNCTION((*fn), p), void *param)
Start a new thread.
gBool gfxSemWaitI(gSem *psem)
Test if a wait on a semaphore can be satisfied immediately.
void gfxSemInit(gSem *psem, gSemcount val, gSemcount limit)
Initialise a Counted Semaphore.
void gfxSemSignalI(gSem *psem)
Signal a semaphore.
void gfxSleepMilliseconds(gDelay ms)
Put the current thread to sleep for the specified period in milliseconds.