System Reference
Data Structures
-
typedef uint32_t
sys_thread_t
Handle to a kernel thread.
-
typedef uint32_t
sys_mutex_t
Handle to a kernel mutex.
-
typedef
sys_thread_func
Function to run inside a thread.
void sys_thread_cb(void* arg)
- Parameters
arg
-Parameter passed to the thread function.
Functions
-
int
sys_thread_create
(sys_thread_t *id, sys_thread_func entry, void *arg, uint32_t *stack_top, int priority, SYSProcessorID idnum) Create a new thread.
Obtains a handle to a thread created by the kernel.
- Return
- On success, 0 is returned. On error, -1 is returned.
- Parameters
id
-Thread ID.
entry
-Function to execute inside the new thread.
arg
-Argument given to the thread function.
stack_top
-Address to use for the thread-specific stack.
priority
-Priority assigned to the new thread.
idnum
-Processor the thread should be created by.
-
int
sys_thread_join
(sys_thread_t id) Wait for a thread to finish.
- Return
- On success, 0 is returned. On error, -1 is returned.
- Parameters
id
-Thread ID.
-
void
sys_thread_sleep
(uint64_t nsec) Put the current thread to sleep.
- Parameters
nsec
-Time to suspend execution, in nanoseconds.
-
void
sys_thread_exit
(void) Exit the current thread.
-
int
sys_mutex_new
(sys_mutex_t *mutex_id, sys_lock_t status) Create a new mutex.
- Return
- On success, 0 is returned. On error, -1 is returned.
- Parameters
mutex_id
-Mutex ID.
status
-Boolean indicating if mutex should be locked upon creation.
-
int
sys_mutex_free
(sys_mutex_t mutex_id) Destroy a mutex variable.
- Return
- On success, 0 is returned. On error, -1 is returned.
- Parameters
mutex_id
-Mutex ID.
-
int
sys_mutex_lock
(sys_mutex_t mutex_id) Lock a mutex variable.
- Return
- On success, 0 is returned. On error, -1 is returned.
- Parameters
mutex_id
-Mutex ID.
-
int
sys_mutex_unlock
(sys_mutex_t mutex_id) Unlock a mutex variable.
- Return
- On success, 0 is returned. On error, -1 is returned.
- Parameters
mutex_id
-Mutex ID.
-
void
sys_debug_printf
(const char *str, ...) Print a debug string.
String is printed to the debug console. On retail consoles this function has no effect. On emulators it will be printed as debug output.
- Parameters
str
-String to print.