stamp.util.os
Class TaskManager

java.lang.Object
  |
  +--stamp.util.os.TaskManager

public class TaskManager
extends Object

Co-operative RTOS This very basic RTOS that does round robin scheduling of tasks.

The TaskManager maintains a linked list of tasks. Each task in the list can be in one of three states: STATE_STOPPED, STATE_READY, STATE_WAITING. The TaskManager iterates around the list of tasks. Each time around the list the execute() method of each task in the STATE_READY state is called and the wait() method of each task in the STATE_WAITING state is called.

Tasks should not block, i.e. they should perform a short action and return to give other tasks an opportunity to run.

Create your own tasks by subclassing the Task class and providing implementations of the execute() and wait() methods.


Field Summary
 Task currentTask
          The task which is currently being executed.
 boolean debug
          Turns on debug mode which will print debugging messages.
static int PUBLIC_STATES
           
static int STATE_READY
           
static int STATE_STOPPED
           
static int STATE_WAITING
           
 
Constructor Summary
TaskManager()
           
 
Method Summary
 void addTask(Task aNewTask)
          Add a task to task list.
 void run()
          This method will run forever executing each task in the readyTask list in a round robin fashion
 
Methods inherited from class java.lang.Object
equals
 

Field Detail

STATE_STOPPED

public static final int STATE_STOPPED

STATE_READY

public static final int STATE_READY

STATE_WAITING

public static final int STATE_WAITING

PUBLIC_STATES

public static final int PUBLIC_STATES

debug

public boolean debug
Turns on debug mode which will print debugging messages.

currentTask

public Task currentTask
The task which is currently being executed.
Constructor Detail

TaskManager

public TaskManager()
Method Detail

addTask

public void addTask(Task aNewTask)
Add a task to task list.
Parameters:
aNewTask - the task to add to the list.

run

public void run()
This method will run forever executing each task in the readyTask list in a round robin fashion