Realtime Scheduler


Data Structures

struct  RTaskNode
struct  RTaskList

Typedefs

typedef unsigned long RTIME
typedef long taskdata
typedef void(* ptask )(taskdata)

Functions

RTaskNodeRTaddtask (ptask task, taskdata arg, RTIME time)
void RTremove_task (RTaskNode *taskptr)
void RTdisable (void)
void RTenable (void)
void RTsaveflags (void)
void RTrestoreflags (void)

Detailed Description

This module contains functions for implementing a real time scheduler The scheduler is intialized by IpacInit and runs on 1.024 ms intervals. This scheduler runs with interrupts enabled and therefore can run longish tasks without risk of slowing down the rest of the system. It's only danger is overflowing the stack, but this can be avoided with some common sense. i.e. don't create a self perpetuating task with a period longer than its reschedule time. Also, when refreshing the screen remember that VT100 commands and ser_printf are not recursive, so they can only run inside one thread at a time.
See also:
ser_printf

Typedef Documentation

typedef void(* ptask)(taskdata)
 

all real time tasks are of type ptask, no return value with a taskdata variable passed to them IMPORTANT: A task passed to the scheduler must have __attribute__((far)) or it will fly off into space when the task is run!

Definition at line 34 of file realtime.h.

typedef unsigned long RTIME
 

type RTIME is used for all time references. It's units are in us

Definition at line 23 of file realtime.h.

typedef long taskdata
 

type taskdata is passed to each real time task, it is commonly used to pass a pointer value

Definition at line 28 of file realtime.h.


Function Documentation

RTaskNode* RTaddtask ptask  task,
taskdata  arg,
RTIME  time
 

adds a task to the scheduler

RTaddtask adds a task to the scheduler. The task is a function of type ptask and will be passed a taskdata arguement when it is called. The taskdata arguement is commonly used to cast a pointer, this will cause the GNU compiler to issue a warning but will work fine. The final arguement, time, is the absolute time the task is scheduled to run in micro-seconds(us), this will therefore need to be the sum of the current system time and the offset when the task is supposed to run. The current system time is stored in the global variable systime which will need to be externally referenced (extern RTIME systime). This variable holds the current system time in us and is updated every 1.024 ms. see the heartbeat function for a simple example of how a task can run and reschedule itself.

Parameters:
task the task to run
arg the arguement to pass to the task when it is run the abolute time to run the task in us
Returns:
a pointer to the task node assigned for the task. This can be used to unschedule a task.
See also:
heartbeat

void RTdisable void   ) 
 

Disable Real Time interrupts

void RTenable void   ) 
 

Enable Real Time interrupts

void RTremove_task RTaskNode taskptr  ) 
 

remove a task from the task list remember that a task is reassigned a node every time it's scheduled, so if a task is rescheduling itself and you want to be able to stop it you'll need to keep track of the pointers coming back from the RTaddtask call..

Parameters:
taskptr the node to pull, this should be the value returned from RTaddtask

void RTrestoreflags void   ) 
 

Restore the interrupt state saved by RTsaveflags

See also:
RTsaveflags

void RTsaveflags void   ) 
 

Disable Real Time interrupts and save their current state


Generated on Fri Mar 3 17:25:46 2006 for EMAC-HCS12-SDK by  doxygen 1.4.6