This library constists of two parts: a platform independent part, which is the same for all platforms on which Contiki runs, and a platform specific part, which must be implemented specifically for the platform that the multi-threading library should run.
Modules | |
Architecture support for multi-threading | |
The Contiki multi-threading library requires some architecture specific support for seting up and switching stacks. | |
Multi-threading library convenience functions | |
The Contiki multi-threading library has an interface that might be hard to use. | |
Defines | |
#define | MT_OK |
No error. | |
Functions | |
void | mt_init (void) |
Initializes the multithreading library. | |
void | mt_remove (void) |
Uninstalls library and cleans up. | |
void | mt_start (struct mt_thread *thread, void(*function)(void *), void *data) |
Starts a multithreading thread. | |
void | mt_exec (struct mt_thread *thread) |
Execute parts of a thread. | |
void | mt_exec_event (struct mt_thread *thread, process_event_t s, process_data_t data) |
Post an event to a thread. | |
void | mt_yield (void) |
Voluntarily give up the processor. | |
void | mt_post (struct process *p, process_event_t ev, process_data_t data) |
Post an event to another process. | |
void | mt_wait (process_event_t *ev, process_data_t *data) |
Block and wait for an event to occur. | |
void | mt_exit (void) |
Exit a thread. |
|
Execute parts of a thread. This function is called by a Contiki process and runs a thread. The function does not return until the thread has yielded, or is preempted.
Definition at line 82 of file mt.c. References MT_STATE_PEEK, MT_STATE_READY, MT_STATE_RUNNING, mtarch_exec(), mt_thread::state, and mt_thread::thread. |
|
Post an event to a thread. This function posts an event to a thread. The thread will be scheduled if the thread currently is waiting for the posted event number. If the thread is not waiting for the event, this function does nothing.
Definition at line 104 of file mt.c. References mt_thread::dataptr, mt_thread::evptr, MT_STATE_PEEK, MT_STATE_RUNNING, MT_STATE_WAITING, mtarch_exec(), mt_thread::state, and mt_thread::thread. |
|
Exit a thread. This function is called from within an executing thread in order to exit the thread. The function never returns. Definition at line 96 of file mt.c. References MT_STATE_EXITED, mtarch_yield(), NULL, and mt_thread::state. Referenced by mtp_exit(). |
|
Post an event to another process. This function is called by a running thread and will emit a signal to another Contiki process. This will cause the currently executing thread to yield.
Definition at line 134 of file mt.c. References process_post(). |
|
Starts a multithreading thread.
Definition at line 72 of file mt.c. References MT_STATE_READY, mtarch_start(), mt_thread::state, and mt_thread::thread. Referenced by mtp_start(). |
|
Block and wait for an event to occur. This function can be called by a running thread in order to block and wait for an event. The function returns when an event has occured. The event number and the associated data are placed in the variables pointed to by the function arguments.
Definition at line 147 of file mt.c. References mt_thread::dataptr, mt_thread::evptr, MT_STATE_WAITING, mtarch_yield(), NULL, and mt_thread::state. |
|
Voluntarily give up the processor. This function is called by a running thread in order to give up control of the CPU. Definition at line 120 of file mt.c. References MT_STATE_READY, mtarch_yield(), NULL, and mt_thread::state. |