RetroArch
Macros | Typedefs | Functions
lwp.h File Reference

Thread subsystem I. More...

#include <gctypes.h>
Include dependency graph for lwp.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define LWP_CLOSED   -1
 
#define LWP_SUCCESSFUL   0
 
#define LWP_ALREADY_SUSPENDED   1
 
#define LWP_NOT_SUSPENDED   2
 
#define LWP_PRIO_IDLE   0
 
#define LWP_PRIO_HIGHEST   127
 
#define LWP_THREAD_NULL   0xffffffff
 
#define LWP_TQUEUE_NULL   0xffffffff
 

Typedefs

typedef u32 lwp_t
 typedef for the thread context handle More...
 
typedef u32 lwpq_t
 typedef for the thread queue's context handle More...
 

Functions

s32 LWP_CreateThread (lwp_t *thethread, void *(*entry)(void *), void *arg, void *stackbase, u32 stack_size, u8 prio)
 
s32 LWP_SuspendThread (lwp_t thethread)
 Suspend the given thread. More...
 
s32 LWP_ResumeThread (lwp_t thethread)
 Resume the given thread. More...
 
BOOL LWP_ThreadIsSuspended (lwp_t thethread)
 Test whether the given thread is suspended or not. More...
 
lwp_t LWP_GetSelf ()
 Return the handle to the current thread. More...
 
void LWP_SetThreadPriority (lwp_t thethread, u32 prio)
 Set the priority of the given thread. More...
 
void LWP_YieldThread ()
 Yield the current thread to another one with higher priority or if not running at the same priority which state is runnable. More...
 
void LWP_Reschedule (u32 prio)
 Reschedule all threads running at the given priority. More...
 
s32 LWP_JoinThread (lwp_t thethread, void **value_ptr)
 Join the given thread. More...
 
s32 LWP_InitQueue (lwpq_t *thequeue)
 Initialize the thread synchronization queue. More...
 
void LWP_CloseQueue (lwpq_t thequeue)
 Close the thread synchronization queue and releas the handle. More...
 
s32 LWP_ThreadSleep (lwpq_t thequeue)
 Pushes the current thread onto the given thread synchronization queue and sets the thread state to blocked. More...
 
void LWP_ThreadSignal (lwpq_t thequeue)
 Signals one thread to be revmoved from the thread synchronization queue and sets it back to running state. More...
 
void LWP_ThreadBroadcast (lwpq_t thequeue)
 Removes all blocked threads from the thread synchronization queue and sets them back to running state. More...
 

Detailed Description

Thread subsystem I.

Macro Definition Documentation

◆ LWP_ALREADY_SUSPENDED

#define LWP_ALREADY_SUSPENDED   1

◆ LWP_CLOSED

#define LWP_CLOSED   -1

◆ LWP_NOT_SUSPENDED

#define LWP_NOT_SUSPENDED   2

◆ LWP_PRIO_HIGHEST

#define LWP_PRIO_HIGHEST   127

◆ LWP_PRIO_IDLE

#define LWP_PRIO_IDLE   0

◆ LWP_SUCCESSFUL

#define LWP_SUCCESSFUL   0

◆ LWP_THREAD_NULL

#define LWP_THREAD_NULL   0xffffffff

◆ LWP_TQUEUE_NULL

#define LWP_TQUEUE_NULL   0xffffffff

Typedef Documentation

◆ lwp_t

typedef for the thread context handle

◆ lwpq_t

typedef for the thread queue's context handle

Function Documentation

◆ LWP_CloseQueue()

void LWP_CloseQueue ( lwpq_t  thequeue)

Close the thread synchronization queue and releas the handle.

Parameters
[in]thequeuehandle to the thread's synchronization queue
Returns
none
Here is the call graph for this function:

◆ LWP_CreateThread()

s32 LWP_CreateThread ( lwp_t thethread,
void *(*)(void *)  entry,
void arg,
void stackbase,
u32  stack_size,
u8  prio 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ LWP_GetSelf()

lwp_t LWP_GetSelf ( )

Return the handle to the current thread.

Returns
thread context handle
Here is the call graph for this function:
Here is the caller graph for this function:

◆ LWP_InitQueue()

void LWP_InitQueue ( lwpq_t thequeue)

Initialize the thread synchronization queue.

Parameters
[in]thequeuepointer to a lwpq_t handle.
Returns
0 on success, <0 on error
Here is the call graph for this function:
Here is the caller graph for this function:

◆ LWP_JoinThread()

s32 LWP_JoinThread ( lwp_t  thethread,
void **  value_ptr 
)

Join the given thread.

Parameters
[in]thethreadhandle to the thread's context which should be joined to wait on termination.
[in]value_ptrpointer-pointer to a variable to receive the return code of the terminated thread.
Returns
0 on success, <0 on error
Here is the call graph for this function:
Here is the caller graph for this function:

◆ LWP_Reschedule()

void LWP_Reschedule ( u32  prio)

Reschedule all threads running at the given priority.

Parameters
[in]priopriority level to reschedule
Returns
none
Here is the call graph for this function:

◆ LWP_ResumeThread()

s32 LWP_ResumeThread ( lwp_t  thethread)

Resume the given thread.

Parameters
[in]thethreadhandle to the thread context which should be resumed.
Returns
0 on success, <0 on error
Here is the call graph for this function:
Here is the caller graph for this function:

◆ LWP_SetThreadPriority()

void LWP_SetThreadPriority ( lwp_t  thethread,
u32  prio 
)

Set the priority of the given thread.

Parameters
[in]thethreadhandle to the thread context whos priority should be changed. If NULL, the current thread will be taken.
[in]prionew priority to set
Returns
none
Here is the call graph for this function:

◆ LWP_SuspendThread()

s32 LWP_SuspendThread ( lwp_t  thethread)

Suspend the given thread.

Parameters
[in]thethreadhandle to the thread context which should be suspended.
Returns
0 on success, <0 on error
Here is the call graph for this function:
Here is the caller graph for this function:

◆ LWP_ThreadBroadcast()

void LWP_ThreadBroadcast ( lwpq_t  thequeue)

Removes all blocked threads from the thread synchronization queue and sets them back to running state.

Parameters
[in]thequeuehandle to the thread's synchronization queue to pop the blocked threads off
Returns
none
Here is the call graph for this function:
Here is the caller graph for this function:

◆ LWP_ThreadIsSuspended()

BOOL LWP_ThreadIsSuspended ( lwp_t  thethread)

Test whether the given thread is suspended or not.

Parameters
[in]thethreadhandle to the thread context which should be tested.
Returns
TRUE or FALSE
Here is the call graph for this function:

◆ LWP_ThreadSignal()

void LWP_ThreadSignal ( lwpq_t  thequeue)

Signals one thread to be revmoved from the thread synchronization queue and sets it back to running state.

Parameters
[in]thequeuehandle to the thread's synchronization queue to pop the blocked thread off
Returns
none
Here is the call graph for this function:
Here is the caller graph for this function:

◆ LWP_ThreadSleep()

s32 LWP_ThreadSleep ( lwpq_t  thequeue)

Pushes the current thread onto the given thread synchronization queue and sets the thread state to blocked.

Parameters
[in]thequeuehandle to the thread's synchronization queue to push the thread on
Returns
none
Here is the call graph for this function:
Here is the caller graph for this function:

◆ LWP_YieldThread()

void LWP_YieldThread ( )

Yield the current thread to another one with higher priority or if not running at the same priority which state is runnable.

Returns
none
Here is the call graph for this function: