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

Multi-threading library convenience functions
[Multi-threading library]


Detailed Description

The Contiki multi-threading library has an interface that might be hard to use. Therefore, the mtp module provides a simpler interface.

Example:

static void example_thread_code(void *data) { while(1) { printf("Test\n"); mt_yield(); } } MTP(example_thread, "Example thread", p1, t1, t1_idle); int main(int argc, char *argv[]) { mtp_start(&example_thread, example_thread_code, NULL); }


Defines

#define MTP(thread, proc, name)
 Declare a thread.


Functions

void mtp_start (struct mtp_thread *t, void(*function)(void *), void *data)
 Start a thread.


Define Documentation

#define MTP thread,
proc,
name   ) 
 

Declare a thread.

This macro is used to covneniently declare a thread, and the process in which the thread should execute. The names of the variables provided to the macro should be chosen to be unique within the file that the thread is used.

Example:

MTP(example_thread, example_proc, "Example thread");

Parameters:
thread The variable name of the thread.
proc The variable name of the process containing the thread.
name A string that specifies the user-visible name of the process in which the thread will run.


Function Documentation

void mtp_start struct mtp_thread *  t,
void(*  function)(void *),
void *  data
 

Start a thread.

This function starts the process in which the thread is to run, and also sets up the thread to run within the process. The function should be passed variable names declared with the MTP() macro.

Example:

mtp_start(&t, example_thread_code, NULL);
Parameters:
t A pointer to a thread structure previously declared with MTP().
function A pointer to the function that the thread should start executing.
data A pointer that the function should be passed when first invocated.


Generated on Wed Jul 6 01:19:06 2005 for Contiki/ESB by doxygen 1.3.6