ME405 Library  Version 0.38
Python library in support of ME405 class
cotask.TaskList Class Reference

A list of tasks used internally by the task scheduler. More...

Public Member Functions

def __init__ (self)
 Initialize the task list. More...
 
def append (self, task)
 Append a task to the task list. More...
 
def rr_sched (self)
 Run tasks in order, ignoring the tasks' priorities. More...
 
def pri_sched (self)
 Run tasks according to their priorities. More...
 
def __repr__ (self)
 Create some diagnostic text showing the tasks in the task list.
 

Public Attributes

 pri_list
 The list of priority lists. More...
 

Detailed Description

A list of tasks used internally by the task scheduler.

This class holds the list of tasks which will be run by the task scheduler. The task list is usually not directly used by the programmer except when tasks are added to it and the scheduler is called. An example showing the use of the task list is given in the last few lines of the documentation for class Task.

The task list is sorted by priority so that the scheduler can efficiently look through the list to find the highest priority task which is ready to run at any given time. Tasks can also be scheduled in a simpler "round-robin" fashion.

Constructor & Destructor Documentation

◆ __init__()

def cotask.TaskList.__init__ (   self)

Initialize the task list.

This creates the list of priorities in which tasks will be organized by priority.

Member Function Documentation

◆ append()

def cotask.TaskList.append (   self,
  task 
)

Append a task to the task list.

The list will be sorted by task priorities so that the scheduler can quickly find the highest priority task which is ready to run at any given time.

Parameters
taskThe task to be appended to the list

◆ pri_sched()

def cotask.TaskList.pri_sched (   self)

Run tasks according to their priorities.

This scheduler runs tasks in a priority based fashion. Each time it is called, it finds the highest priority task which is ready to run and calls that task's run() method.

◆ rr_sched()

def cotask.TaskList.rr_sched (   self)

Run tasks in order, ignoring the tasks' priorities.

This scheduling method runs tasks in a round-robin fashion. Each time it is called, it goes through the list of tasks and gives each of them a chance to run. Although this scheduler first runs higher priority tasks first, that has no significant effect in the long run, as all the tasks are given a chance to run each time through the list, and it takes about the same amount of time before each is given a chance to run again.

Member Data Documentation

◆ pri_list

cotask.TaskList.pri_list

The list of priority lists.

Each priority for which at least one task has been created has a list whose first element is a task priority and whose other elements are references to task objects at that priority.


The documentation for this class was generated from the following file: