os.h File Reference

A simple RTOS interface. More...

Go to the source code of this file.

Defines

#define MAXPROCESS   8
#define MAXEVENT   8
#define WORKSPACE   256
#define TICK   5
#define SYSTEM   3
#define PERIODIC   2
#define RR   1
#define NULL   0
#define IDLE   0

Typedefs

typedef event EVENT

Functions

void OS_Init (void)
 Setup the RTOS and create main() as the first SYSTEM level task.
void OS_Abort (void)
 Abort the execution of this RTOS due to an unrecoverable erorr.
int Task_Create (void(*f)(void), int arg, unsigned int level, unsigned int name)
void Task_Terminate (void)
 The calling task terminates itself.
void Task_Next (void)
 The calling task gives up its share of the processor voluntarily.
int Task_GetArg (void)
 Retrieve the assigned parameter.
EVENTEvent_Init (void)
 Initialize a new, non-NULL Event descriptor.
void Event_Wait (EVENT *e)
 Wait for the next occurrence of a signal on e. The calling process always blocks.
void Event_Signal (EVENT *e)
 Resume a single waiting task on e. It is a no-op if there is no waiting process.
void Event_Broadcast (EVENT *e)
 Resume ALL waiting tasks on e. It is a no-op if there is no waiting process.
void Signal_And_Next (EVENT *e)
 Resume a waiting task on e and at the same time relinquish the processor.
void Broadcast_And_Next (EVENT *e)
 Resume ALL waiting tasks on e and at the same time relinquish the processor.

Variables

const unsigned char PPP []
const unsigned int PT


Detailed Description

A simple RTOS interface.

Definition in file os.h.


Define Documentation

#define MAXPROCESS   8

max. number of processes supported

Definition at line 148 of file os.h.

#define MAXEVENT   8

max. number of Events supported

Definition at line 151 of file os.h.

#define WORKSPACE   256

workspace size of each process in bytes

Definition at line 154 of file os.h.

#define TICK   5

milliseconds, or something close to this value

See also:
PERIODIC TASKS.

Definition at line 159 of file os.h.

#define SYSTEM   3

a scheduling level: system tasks with first-come-first-served policy

See also:
SYSTEM TASKS, Task_Create().

Definition at line 166 of file os.h.

#define PERIODIC   2

a scheduling level: periodic tasks with predefined intervals

See also:
PERIODIC TASKS, Task_Create().

Definition at line 171 of file os.h.

#define RR   1

A scheduling level: first-come-first-served cooperative tasks

See also:
RR TASKS, Task_Create().

Definition at line 176 of file os.h.

#define NULL   0

Definition at line 178 of file os.h.

#define IDLE   0

Definition at line 179 of file os.h.


Typedef Documentation

typedef struct event EVENT

An Event descriptor

See also:
Event_Init().

Definition at line 188 of file os.h.


Function Documentation

void OS_Init ( void   ) 

Setup the RTOS and create main() as the first SYSTEM level task.

Point of entry from the C runtime crt0.S.

Definition at line 1015 of file os.c.

void OS_Abort ( void   ) 

Abort the execution of this RTOS due to an unrecoverable erorr.

Abort the execution of this RTOS due to an unrecoverable erorr.

See also:
GLOBAL ASSUMPTIONS.

Definition at line 1096 of file os.c.

int Task_Create ( void(*)(void)  f,
int  arg,
unsigned int  level,
unsigned int  name 
)

Parameters:
f a parameterless function to be created as a process instance
arg an integer argument to be assigned to this process instanace
level assigned scheduling level: SYSTEM, PERIODIC or RR
name assigned PERIODIC process name
Returns:
0 if not successful; otherwise non-zero.
See also:
Task_GetArg(), PPP[].
A new process is created to execute the parameterless function f with an initial parameter arg, which is retrieved by a call to Task_GetArg(). If a new process cannot be created, 0 is returned; otherwise, it returns non-zero. The created process will belong to its scheduling level. If the process is PERIODIC, then its name is a user-specified name to be used in the PPP[] array. Otherwise, name is ignored.
See also:
SCHEDULING POLICY

Definition at line 1177 of file os.c.

void Task_Terminate ( void   ) 

The calling task terminates itself.

Terminate the calling process

When a process returns, i.e., it executes its last instruction in the associated function/code, it is automatically terminated.

Definition at line 1220 of file os.c.

void Task_Next ( void   ) 

The calling task gives up its share of the processor voluntarily.

Voluntarily relinquish the processor.

Definition at line 1203 of file os.c.

int Task_GetArg ( void   ) 

Retrieve the assigned parameter.

Retrieve the assigned parameter.

See also:
Task_Create().

Definition at line 1236 of file os.c.

EVENT* Event_Init ( void   ) 

Initialize a new, non-NULL Event descriptor.

Returns:
a non-NULL Event descriptor if successful; NULL otherwise.

Definition at line 1256 of file os.c.

void Event_Wait ( EVENT e  ) 

Wait for the next occurrence of a signal on e. The calling process always blocks.

Parameters:
e an Event descriptor

Definition at line 1280 of file os.c.

void Event_Signal ( EVENT e  ) 

Resume a single waiting task on e. It is a no-op if there is no waiting process.

Parameters:
e an Event descriptor
See also:
Event_Wait()

Definition at line 1301 of file os.c.

void Event_Broadcast ( EVENT e  ) 

Resume ALL waiting tasks on e. It is a no-op if there is no waiting process.

Parameters:
e an Event descriptor
See also:
Event_Wait()

Definition at line 1322 of file os.c.

void Signal_And_Next ( EVENT e  ) 

Resume a waiting task on e and at the same time relinquish the processor.

Parameters:
e an Event descriptor
This is equivalent to "Event_Signal( e ); Task_Next()" in concept. The fundamental difference is that these two operations are performed as an indivisible unit. So conceptually, the calling task resumes another waiting task and gives up its share of the processor simultaneously.
See also:
Event_Signal(), Task_Next()

Definition at line 1348 of file os.c.

void Broadcast_And_Next ( EVENT e  ) 

Resume ALL waiting tasks on e and at the same time relinquish the processor.

Parameters:
e an Event descriptor
This is equivalent to "Event_Broadcast( e ); Task_Next()" in concept.
See also:
Event_Broadcast(), Task_Next()

Definition at line 1371 of file os.c.


Variable Documentation

const unsigned char PPP[]

A periodic task scheduling plan (read-only, defined by the application).

This is specified by the application. The scheduling ordering and duration of all PERIODIC tasks are specified by this plan. The total number of occurrences of all PERIODIC tasks, including IDLE, is given by PT. e.g., PPP[] = { A, 2, IDLE, 5, B, 1, A, 2, C, 4 }; PT = 5;

See also:
PERIODIC TASKS.

const unsigned int PT


Generated on Tue Oct 23 21:49:51 2007 for RTOS by  doxygen 1.5.1