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

Contiki processes


Detailed Description

A process in Contiki consists of a single Protothreads protothread.


Files

file  process.h
 Header file for the Contiki process interface.


Defines

#define PROCESS_BEGIN()
 Define the beginning of a process.

#define PROCESS_END()
 Define the end of a process.

#define PROCESS_WAIT_EVENT()
 Wait for an event to be posted to the process.

#define PROCESS_WAIT_EVENT_UNTIL(c)
 Wait for an event to be posted to the process, with an extra condition.

#define PROCESS_YIELD()
 Yield the currently running process.

#define PROCESS_YIELD_UNTIL(c)
 Yield the currently running process until a condition occurs.

#define PROCESS_WAIT_UNTIL(c)
 Wait for a condition to occur.

#define PROCESS_EXIT()
 Exit the currently running process.

#define PROCESS_SPAWN(pt, thread)
 Spawn a protothread from the process.

#define PROCESS_PAUSE()
 Yield the process for a short while.

#define PROCESS_THREAD(name, ev, data)
 Define the body of a process.

#define PROCESS_NAME(name)
 Declare the name of a process.

#define PROCESS(name, strname)
 Declare a process.

#define PROCESS_CURRENT()
 Get a pointer to the currently running process.


Functions

int process_post (struct process *p, process_event_t ev, process_data_t data)
 Post an asynchronous event.

int process_run (void)
 Process one event from the event queue.


Define Documentation

#define PROCESS name,
strname   ) 
 

Declare a process.

This macro declares a process with the variable name of the process, and a textual repressentation of the process (used mainly for debugging).

Examples:
example-program.c, example-service.c, and example-use-service.c.

 
#define PROCESS_BEGIN  ) 
 

Define the beginning of a process.

This macro defines the beginning of a process, and must always appear in a PROCESS_THREAD() definition. The PROCESS_END() macro must come at the end of the process.

Examples:
example-program.c, example-service.c, and example-use-service.c.

 
#define PROCESS_CURRENT  ) 
 

Get a pointer to the currently running process.

This macro get a pointer to the currently running process. Typically, this macro is used to post an event to the current process with process_post().

 
#define PROCESS_END  ) 
 

Define the end of a process.

This macro defines the end of a process. It must appear in a PROCESS_THREAD() definition and must always be included. The process exits when the PROCESS_END() macro is reached.

Examples:
example-program.c, example-service.c, and example-use-service.c.

#define PROCESS_NAME name   ) 
 

Declare the name of a process.

This macro is typically used in header files to declare the name of a process that is implemented in the C file.

 
#define PROCESS_PAUSE  ) 
 

Yield the process for a short while.

This macro yields the currently running process for a short while, thus letting other processes run before the process continues.

#define PROCESS_SPAWN pt,
thread   ) 
 

Spawn a protothread from the process.

Parameters:
pt The protothread state (struct pt) for the new protothread
thread The call to the protothread function.
See also:
PT_SPAWN()

#define PROCESS_THREAD name,
ev,
data   ) 
 

Value:

static PT_THREAD(process_thread_##name(struct pt *process_pt,   \
                                       process_event_t ev,      \
                                       process_data_t data))
Define the body of a process.

This macro is used to define the body (protothread) of a process. The process is called whenever an event occurs in the system, A process always start with the PROCESS_BEGIN() macro and end with the PROCESS_END() macro.

Examples:
example-program.c, example-service.c, and example-use-service.c.

 
#define PROCESS_WAIT_EVENT  ) 
 

Wait for an event to be posted to the process.

This macro blocks the currently running process until the process receives an event.

#define PROCESS_WAIT_EVENT_UNTIL  ) 
 

Wait for an event to be posted to the process, with an extra condition.

This macro is similar to PROCESS_WAIT_EVENT() in that it blocks the currently running process until the process receives an event. But PROCESS_WAIT_EVENT_UNTIL() takes an extra condition which must be true for the process to continue.

Parameters:
c The condition that must be true for the process to continue.
See also:
PT_WAIT_UNTIL()
Examples:
example-program.c.

#define PROCESS_WAIT_UNTIL  ) 
 

Wait for a condition to occur.

This macro does not guarantee that the process yields, and should therefore be used with care. In most cases, PROCESS_WAIT_EVENT(), PROCESS_WAIT_EVENT_UNTIL(), PROCESS_YIELD() or PROCESS_YIELD_UNTIL() should be used instead.

Parameters:
c The condition to wait for.

#define PROCESS_YIELD_UNTIL  ) 
 

Yield the currently running process until a condition occurs.

This macro is different from PROCESS_WAIT_UNTIL() in that PROCESS_YIELD_UNTIL() is guaranteed to always yield at least once. This ensures that the process does not end up in an infinite loop and monopolizing the CPU.

Parameters:
c The condition to wait for.
Examples:
example-service.c, and example-use-service.c.


Function Documentation

int process_post struct process *  p,
process_event_t  ev,
process_data_t  data
 

Post an asynchronous event.

This function posts an asynchronous event to one or more processes. The handing of the event is deferred until the target process is scheduled by the kernel. An event can be broadcast to all processes, in which case all processes in the system will be scheduled to handle the event.

Parameters:
s The event to be posted.
data The auxillary data to be sent with the event
id The process ID to which the event should be posted, or PROCESS_BROADCAST if the event should be posted to all processes.
Return values:
PROCESS_ERR_OK The event could be posted.
PROCESS_ERR_FULL The event queue was full and the event could not be posted.

int process_run void   ) 
 

Process one event from the event queue.

This function should be called repeatedly from the main() program to actuall run the Contiki system. It calls the necessary poll handlers, and processes one event. The function returns the number of events that are waiting in the event queue so that the caller may choose to put the CPU to sleep when there are no pending events.

Returns:
The number of events that are currently waiting in the event queue.


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