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

Contiki processes
[Contiki system]


Detailed Description

A process in Contiki consists of a single Protothreads protothread.


Files

file  process.c
 Implementation of the Contiki process kernel.
file  process.h
 Header file for the Contiki process interface.

Defines

#define PROCESS_STATE_NONE   0
#define PROCESS_STATE_INIT   1
#define PROCESS_STATE_RUNNING   2
#define PROCESS_STATE_NEEDS_POLL   3

Typedefs

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

Functions

process_event_t process_alloc_event (void)
 Allocate a global event number.
void process_start (struct process *p, char *arg)
 Start a process.
void process_exit (struct process *p)
 Cause a process to exit.
void process_init (void)
 Initialize the process module.
int process_run (void)
 Run the system once - call poll handlers and process one event.
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_poll (struct process *p)
 Request a process to be polled.

Variables

processprocess_list = NULL
processprocess_current = NULL


Function Documentation

process_event_t process_alloc_event void   ) 
 

Allocate a global event number.

Returns:
The allocated event number
In Contiki, event numbers above 128 are global and may be posted from one process to another. This function allocates one such event number.

Note:
There currently is no way to deallocate an allocated event number.

Definition at line 90 of file process.c.

Referenced by PROCESS_THREAD().

void process_exit struct process p  ) 
 

Cause a process to exit.

Parameters:
p The process that is to be exited
This function causes a process to exit. The process can either be the currently executing process, or another process that is currently running.

See also:
PROCESS_CURRENT()

Definition at line 203 of file process.c.

References PROCESS_CURRENT.

void process_init void   ) 
 

Initialize the process module.

This function initializes the process module and should be called by the system boot-up code.

Definition at line 209 of file process.c.

References NULL, and PROCESS_EVENT_MAX.

void process_poll struct process p  ) 
 

Request a process to be polled.

This function typically is called from an interrupt handler to cause a process to be polled.

Parameters:
p A pointer to the process' process structure.
Examples:
example-packet-service.c.

Definition at line 384 of file process.c.

References NULL, PROCESS_STATE_NEEDS_POLL, PROCESS_STATE_RUNNING, and state.

Referenced by etimer_request_poll(), and PROCESS_THREAD().

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:
ev The event to be posted.
data The auxillary data to be sent with the event
p The process 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.

Definition at line 356 of file process.c.

References PROCESS_ERR_FULL, and PROCESS_ERR_OK.

Referenced by mt_post(), process_start(), PROCESS_THREAD(), program_handler_load(), resolv_conf(), resolv_found(), service_remove(), tcpip_poll_tcp(), and tcpip_poll_udp().

void process_post_synch struct process p,
process_event_t  ev,
process_data_t  data
 

Post a synchronous event to a process.

Parameters:
p A pointer to the process' process structure.
ev The event to be posted.
data A pointer to additional data that is posted together with the event.

Definition at line 375 of file process.c.

Referenced by PROCESS_THREAD(), tcpip_input(), and tcpip_uipcall().

int process_run void   ) 
 

Run the system once - call poll handlers and process one event.

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.

Definition at line 342 of file process.c.

void process_start struct process p,
char *  arg
 

Start a process.

Parameters:
p A pointer to a process structure.
arg An argument pointer that can be passed to the new process

Definition at line 96 of file process.c.

References next, NULL, PROCESS_EVENT_INIT, process_post(), PROCESS_STATE_INIT, pt, PT_INIT, and state.

Referenced by mtp_start().


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