This support requires three stack manipulation functions to be implemented: mtarch_start(), which sets up the stack frame for a new thread, mtarch_exec(), which switches in the stack of a thread, and mtarch_yield(), which restores the kernel stack from a thread's stack. Additionally, two functions for controlling the preemption (if any) must be implemented: mtarch_preemption_start() and mtarch_preemption_stop(). If no preemption is used, these functions can be implemented as empty functions. Finally, the function mtarch_init() is called by mt_init(), and can be used for initalization of timer interrupts, or any other mechanisms required for correct operation of the architecture specific support funcions.
Files | |
file | mt.h |
Header file for the preemptive multitasking library for Contiki. | |
Functions | |
void | mtarch_init (void) |
Initialize the architecture specific support functions for the multi-thread library. | |
void | mtarch_remove (void) |
Uninstall library and clean up. | |
void | mtarch_start (struct mtarch_thread *thread, void(*function)(void *data), void *data) |
Setup the stack frame for a thread that is being started. | |
void | mtarch_yield (void) |
Yield the processor. | |
void | mtarch_exec (struct mtarch_thread *thread) |
Start executing a thread. |
|
Start executing a thread. This function is called from mt_exec() and the purpose of the function is to start execution of the thread. The function should switch in the stack of the thread, and does not return until the thread has explicitly yielded (using mt_yield()) or until it is preempted. Referenced by mt_exec(), and mt_exec_event(). |
|
Initialize the architecture specific support functions for the multi-thread library. This function is implemented by the architecture specific functions for the multi-thread library and is called by the mt_init() function as part of the initialization of the library. The mtarch_init() function can be used for, e.g., starting preemtion timers or other architecture specific mechanisms required for the operation of the library. Referenced by mt_init(). |
|
Setup the stack frame for a thread that is being started. This function is called by the mt_start() function in order to set up the architecture specific stack of the thread to be started.
Referenced by mt_start(). |
|
Yield the processor. This function is called by the mt_yield() function, which is called from the running thread in order to give up the processor. Referenced by mt_exit(), mt_peek(), mt_wait(), and mt_yield(). |