Main Page | Modules | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Examples

Architecture support for multi-threading
[Multi-threading library]


Detailed Description

The Contiki multi-threading library requires some architecture specific support for seting up and switching stacks.

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.


Function Documentation

void mtarch_exec struct mtarch_thread *  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().

void mtarch_init void   ) 
 

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().

void mtarch_start struct mtarch_thread *  thread,
void(*)(void *data)  function,
void *  data
 

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.

Parameters:
thread A pointer to a struct mtarch_thread for the thread to be started.
function A pointer to the function that the thread will start executing the first time it is scheduled to run.
data A pointer to the argument that the function should be passed.

Referenced by mt_start().

void mtarch_yield void   ) 
 

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().


Generated on Thu Jun 22 17:45:43 2006 for Contiki 2.x by  doxygen 1.4.4