Go to the source code of this file.
Data Structures | |
| struct | thread_t |
Defines | |
| #define | TICK2US(x) (((x) * 4) / 243) |
| #define | US2TICK(x) (((x) * 243) / 4) |
| #define | DEC_TIMER (100) |
Enumerations | |
| enum | thread_state_t { THREAD_EXITED = -2, THREAD_UNRUNNABLE = -1, THREAD_RUNNABLE = 0 } |
Functions | |
| int | threads_initialize (void) |
| Initialize the threading subsystem. | |
| int | threads_shutdown (void) |
| Shut down the threading subsystem. | |
| int | threads_create (int priority, thread_state_t state, void *stack, u32 stacksize, void *pc) |
| Create a thread. | |
| int | threads_create_adv (int priority, thread_state_t state, void *stack, void *pc, u32 msr, u32 ctr, u32 xer, u32 cr, u32 lr, u32 fpscr, u32 gprs[32], u64 fprs[32]) |
| Create a thread. | |
| int | threads_get_pid (void) |
| Get's the PID of the current thread. | |
| int | threads_destroy (int pid) |
| Destroy a thread. | |
| void | threads_exit (int code) |
| Exits the current thread. | |
| int | threads_state (int pid) |
| Get the state of a thread. | |
| int | threads_exitcode (int pid) |
| Get the exit code of a thread. | |
| void | threads_yield (void) |
| Yield the current thread to the scheduler. | |
| int | threads_freeze (void) |
| Freeze the scheduler. | |
| void | threads_unfreeze (int frz) |
| Unfreeze the scheduler. | |
A threading API written specifically for the Wii for mini-broadway.
| int threads_create | ( | int | priority, | |
| thread_state_t | state, | |||
| void * | stack, | |||
| u32 | stacksize, | |||
| void * | pc | |||
| ) |
Create a thread.
A simple method to create a thread.
| priority | the priority level of the thread. Range from -5 to 5. | |
| state | the beginning state of the thread. | |
| stack | a pointer to a section of memory to be used as the thread's stack. | |
| stacksize | the size of the stack for the thread. | |
| pc | a function to be executed by the thread. |
| int threads_create_adv | ( | int | priority, | |
| thread_state_t | state, | |||
| void * | stack, | |||
| void * | pc, | |||
| u32 | msr, | |||
| u32 | ctr, | |||
| u32 | xer, | |||
| u32 | cr, | |||
| u32 | lr, | |||
| u32 | fpscr, | |||
| u32 | gprs[32], | |||
| u64 | fprs[32] | |||
| ) |
Create a thread.
A complex method to create a thread.
| priority | the priority level of the thread. Range from -5 to 5. | |
| state | the beginning state of the thread. | |
| stack | a pointer to a section of memory to be used as the thread's stack. | |
| pc | a function to be executed by the thread. | |
| msr | the MSR of the new thread. | |
| ctr | the CTR of the new thread. | |
| xer | the XER of the new thread. | |
| cr | the CR of the new thread. | |
| lr | the LR of the new thread. | |
| fpscr | the FPSCR of the new thread. | |
| gprs | the GPRs of the new thread. You must have r1 set to the stack, as this function will not automatically set it for you. | |
| fprs | the FPRs of the new thread. |
| int threads_destroy | ( | int | pid | ) |
Destroy a thread.
Ends execution of a thread with specified PID, and removes it from the queue.
| pid | the PID of the thread to destroy. |
| void threads_exit | ( | int | code | ) |
Exits the current thread.
Ends execution of the current thread, and disables it from running. The thread still will remain in the queue however, so make sure to destroy it later with threads_destroy().
| code | the exit code for the thread to go out on. |
| int threads_exitcode | ( | int | pid | ) |
Get the exit code of a thread.
Returns the exit code of the thread with the specified PID. If the thread has not yet exited, this value will be 0.
| pid | the PID of the thread to get the exit code of. |
| int threads_freeze | ( | void | ) |
Freeze the scheduler.
BE EXTREMELY CAREFUL WITH THIS FUNCTION, AS IMPROPER USE WILL LEAD TO A COMPLETE LOCKUP. Freeze the scheduler and disable external interrupts in order to provide a safe area for no scheduler disruptions.
| int threads_get_pid | ( | void | ) |
Get's the PID of the current thread.
| int threads_initialize | ( | void | ) |
Initialize the threading subsystem.
Initializes the threading subsystem, registers the handler for the decrementer and performs all other required initialization tasks.
| int threads_shutdown | ( | void | ) |
Shut down the threading subsystem.
Shuts down the threading subsystem, unregisters the handler for the decrementer and performs all other required shut down tasks.
| int threads_state | ( | int | pid | ) |
Get the state of a thread.
Returns the state of the thread with the specified PID.
| pid | the PID of the thread to get the state of. |
| void threads_unfreeze | ( | int | frz | ) |
Unfreeze the scheduler.
Unfreeze the scheduler and re-enable external interrupts if they were as such before the freeze that the cookie corresponds to.
| frz | the cookie returned from the corresponding threads_freeze() call. |
| void threads_yield | ( | void | ) |
Yield the current thread to the scheduler.
The current thread suspends execution and gives the remainder of its time up to the scheduler and other threads.
1.6.3