Thread subsystem I. More...
#include <gctypes.h>Defines | |
| #define | LWP_ALLREADY_SUSPENDED 1 |
| #define | LWP_CLOSED -1 |
| #define | LWP_NOT_SUSPENDED 2 |
| #define | LWP_PRIO_HIGHEST 127 |
| #define | LWP_PRIO_IDLE 0 |
| #define | LWP_SUCCESSFUL 0 |
| #define | LWP_THREAD_NULL 0xffffffff |
| #define | LWP_TQUEUE_NULL 0xffffffff |
Typedefs | |
| typedef u32 | lwp_t |
| typedef for the thread context handle | |
| typedef u32 | lwpq_t |
| typedef for the thread queue's context handle | |
Functions | |
| void | LWP_CloseQueue (lwpq_t thequeue) |
| Close the thread synchronization queue and releas the handle. | |
| s32 | LWP_CreateThread (lwp_t *thethread, void *(*entry)(void *), void *arg, void *stackbase, u32 stack_size, u8 prio) |
| Spawn a new thread with the given parameters. | |
| lwp_t | LWP_GetSelf () |
| Return the handle to the current thread. | |
| s32 | LWP_InitQueue (lwpq_t *thequeue) |
| Initialize the thread synchronization queue. | |
| s32 | LWP_JoinThread (lwp_t thethread, void **value_ptr) |
| Join the given thread. | |
| void | LWP_Reschedule (u32 prio) |
| Reschedule all threads running at the given priority. | |
| s32 | LWP_ResumeThread (lwp_t thethread) |
| Resume the given thread. | |
| void | LWP_SetThreadPriority (lwp_t thethread, u32 prio) |
| Set the priority of the given thread. | |
| s32 | LWP_SuspendThread (lwp_t thethread) |
| Suspend the given thread. | |
| void | LWP_ThreadBroadcast (lwpq_t thequeue) |
| Removes all blocked threads from the thread synchronization queue and sets them back to running state. | |
| BOOL | LWP_ThreadIsSuspended (lwp_t thethread) |
| Test whether the given thread is suspended or not. | |
| void | LWP_ThreadSignal (lwpq_t thequeue) |
| Signals one thread to be revmoved from the thread synchronization queue and sets it back to running state. | |
| s32 | LWP_ThreadSleep (lwpq_t thequeue) |
| Pushes the current thread onto the given thread synchronization queue and sets the thread state to blocked. | |
| 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. | |
Thread subsystem I.
| void LWP_CloseQueue | ( | lwpq_t | thequeue | ) |
Close the thread synchronization queue and releas the handle.
| [in] | thequeue | handle to the thread's synchronization queue |
| s32 LWP_CreateThread | ( | lwp_t * | thethread, | |
| void *(*)(void *) | entry, | |||
| void * | arg, | |||
| void * | stackbase, | |||
| u32 | stack_size, | |||
| u8 | prio | |||
| ) |
Spawn a new thread with the given parameters.
| [out] | thethread | pointer to a lwp_t handle |
| [in] | entry | pointer to the thread's entry function. |
| [in] | arg | pointer to an argument for the thread's entry function. |
| [in] | stackbase | pointer to the threads stackbase address. If NULL, the stack is allocated by the thread system. |
| [in] | stack_size | size of the provided stack. If 0, the default STACKSIZE of 8Kb is taken. |
| [in] | prio | priority on which the newly created thread runs. |
| lwp_t LWP_GetSelf | ( | ) |
Return the handle to the current thread.
| void LWP_InitQueue | ( | lwpq_t * | thequeue | ) |
Initialize the thread synchronization queue.
| [in] | thequeue | pointer to a lwpq_t handle. |
Join the given thread.
| [in] | thethread | handle to the thread's context which should be joined to wait on termination. |
| [in] | value_ptr | pointer-pointer to a variable to receive the return code of the terminated thread. |
| void LWP_Reschedule | ( | u32 | prio | ) |
Reschedule all threads running at the given priority.
| [in] | prio | priority level to reschedule |
Resume the given thread.
| [in] | thethread | handle to the thread context which should be resumed. |
Set the priority of the given thread.
| [in] | thethread | handle to the thread context whos priority should be changed. If NULL, the current thread will be taken. |
| [in] | prio | new priority to set |
Suspend the given thread.
| [in] | thethread | handle to the thread context which should be suspended. |
| void LWP_ThreadBroadcast | ( | lwpq_t | thequeue | ) |
Removes all blocked threads from the thread synchronization queue and sets them back to running state.
| [in] | thequeue | handle to the thread's synchronization queue to pop the blocked threads off |
| BOOL LWP_ThreadIsSuspended | ( | lwp_t | thethread | ) |
Test whether the given thread is suspended or not.
| [in] | thethread | handle to the thread context which should be tested. |
| void LWP_ThreadSignal | ( | lwpq_t | thequeue | ) |
Signals one thread to be revmoved from the thread synchronization queue and sets it back to running state.
| [in] | thequeue | handle to the thread's synchronization queue to pop the blocked thread off |
Pushes the current thread onto the given thread synchronization queue and sets the thread state to blocked.
| [in] | thequeue | handle to the thread's synchronization queue to push the thread on |
| 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.
1.6.3