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

process.h File Reference


Detailed Description

Header file for the Contiki process interface.

Author:
Adam Dunkels <adam@sics.se>

Definition in file process.h.

#include "sys/pt.h"
#include "sys/cc.h"

Go to the source code of this file.

Data Structures

struct  process

Return values

#define PROCESS_ERR_OK   0
 Return value indicating that an operation was successful.
#define PROCESS_ERR_FULL   1
 Return value indicating that the event queue was full.

Process protothread functions

#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.

Poll and exit handlers

#define PROCESS_POLLHANDLER(handler)
 Specify an action when a process is polled.
#define PROCESS_EXITHANDLER(handler)
 Specify an action when a process exits.

Process declaration and definion

#define PROCESS_THREAD(name, ev, data)
 Define the body of a process.
#define PROCESS_LOAD(name)
#define PROCESS_NAME(name)
 Declare the name of a process.
#define PROCESS_NOLOAD(name, strname)
 Declare a process that should not be automatically loaded.
#define PROCESS(name, strname)
 Declare a process.

Functions called from application programs

#define PROCESS_CURRENT()
 Get a pointer to the currently running process.
#define PROCESS_SET_FLAGS(flags)
#define PROCESS_NO_BROADCAST
#define PROCESS_CONTEXT_BEGIN(p)
 Switch context to another process.
#define PROCESS_CONTEXT_END(p)   process_current = tmp_current; }
 End a context switch.
void process_start (struct process *p, char *arg)
 Start a process.
int process_post (struct process *p, process_event_t ev, process_data_t data)
 Post an asynchronous event.
void process_post_synch (struct process *p, process_event_t ev, process_data_t data)
 Post a synchronous event to a process.
void process_exit (struct process *p)
 Cause a process to exit.
process_event_t process_alloc_event (void)
 Allocate a global event number.
processprocess_current

Functions called from device drivers

void process_poll (struct process *p)
 Request a process to be polled.

Functions called by the system and boot-up code

void process_init (void)
 Initialize the process module.
int process_run (void)
 Run the system once - call poll handlers and process one event.

Defines

#define PROCESS_NONE   NULL
#define PROCESS_CONF_NUMEVENTS   32
#define PROCESS_EVENT_NONE   0x80
#define PROCESS_EVENT_INIT   0x81
#define PROCESS_EVENT_POLL   0x82
#define PROCESS_EVENT_EXIT   0x83
#define PROCESS_EVENT_SERVICE_REMOVED   0x84
#define PROCESS_EVENT_CONTINUE   0x85
#define PROCESS_EVENT_MSG   0x86
#define PROCESS_EVENT_EXITED   0x87
#define PROCESS_EVENT_TIMER   0x88
#define PROCESS_EVENT_MAX   0x89
#define PROCESS_BROADCAST   NULL
#define PROCESS_ZOMBIE   ((struct process *)0x1)
#define PROCESS_LIST()   process_list

Typedefs

typedef unsigned char process_event_t
typedef void * process_data_t
typedef unsigned char process_num_events_t

Variables

processprocess_list


Define Documentation

#define PROCESS name,
strname   ) 
 

Declare a process.

This macro declares a process. The process has two names: the variable of the process structure, which is used by the C program, and a human readable string name, which is used when debugging.

Note:
For programs that are compiled as loadable programs: the process declared with the PROCESS() declaration will be automatically started when the program is loaded. The PROCESS_NOLOAD() declaration can be used to declare a process that shouldn't be automatically loaded.
Parameters:
name The variable name of the process structure.
strname The string repressentation of the process' name.
Examples:
example-packet-service.c, example-pollhandler.c, example-program.c, example-psock-server.c, example-service.c, and example-use-service.c.

Definition at line 326 of file process.h.

 
#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-packet-service.c, example-pollhandler.c, example-program.c, example-psock-server.c, example-service.c, and example-use-service.c.

Definition at line 120 of file process.h.

Referenced by PROCESS_THREAD().

#define PROCESS_CONTEXT_BEGIN  ) 
 

Value:

{\
struct process *tmp_current = PROCESS_CURRENT();\
process_current = p
Switch context to another process.

This function switch context to the specified process and executes the code as if run by that process. Typical use of this function is to switch context in services, called by other processes. Each PROCESS_CONTEXT_BEGIN() must be followed by the PROCESS_CONTEXT_END() macro to end the context switch.

Example:

Parameters:
p The process to use as context
See also:
PROCESS_CONTEXT_END()

PROCESS_CURRENT()

Definition at line 441 of file process.h.

#define PROCESS_CONTEXT_END  )     process_current = tmp_current; }
 

End a context switch.

This function ends a context switch and changes back to the previous process.

Parameters:
p The process used in the context switch
See also:
PROCESS_CONTEXT_START()

Definition at line 455 of file process.h.

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

Definition at line 414 of file process.h.

Referenced by ctk_desktop_redraw(), process_exit(), service_register(), tcp_attach(), tcp_connect(), tcp_listen(), tcp_unlisten(), udp_attach(), and udp_new().

 
#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-packet-service.c, example-pollhandler.c, example-program.c, example-psock-server.c, example-service.c, and example-use-service.c.

Definition at line 131 of file process.h.

Referenced by PROCESS_THREAD().

#define PROCESS_EXITHANDLER handler   ) 
 

Specify an action when a process exits.

Note:
This declaration must come immediately before the PROCESS_BEGIN() macro.
Parameters:
handler The action to be performed.
Examples:
example-pollhandler.c, and example-service.c.

Definition at line 253 of file process.h.

#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.

Definition at line 292 of file process.h.

#define PROCESS_NOLOAD name,
strname   ) 
 

Declare a process that should not be automatically loaded.

This macro is similar to the PROCESS() declaration, with the difference that for programs that are compiled as loadable programs, processes declared with the PROCESS_NOLOAD() declaration will not be automatically started when the program is loaded.

Definition at line 304 of file process.h.

 
#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.

Definition at line 220 of file process.h.

#define PROCESS_POLLHANDLER handler   ) 
 

Specify an action when a process is polled.

Note:
This declaration must come immediately before the PROCESS_BEGIN() macro.
Parameters:
handler The action to be performed.
Examples:
example-packet-service.c, and example-pollhandler.c.

Definition at line 241 of file process.h.

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

Definition at line 210 of file process.h.

#define PROCESS_THREAD name,
ev,
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-packet-service.c, example-pollhandler.c, example-program.c, example-psock-server.c, example-service.c, and example-use-service.c.

Definition at line 272 of file process.h.

 
#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.

Examples:
example-pollhandler.c.

Definition at line 141 of file process.h.

Referenced by PROCESS_THREAD().

#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-packet-service.c, example-program.c, and example-psock-server.c.

Definition at line 157 of file process.h.

#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.

Definition at line 192 of file process.h.

#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.

Definition at line 178 of file process.h.


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