ME405: Mechatronics
Project Documentation and Portfolio by Neil Patel
cotask.TaskList Class Reference

This class holds the list of tasks which will be run 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)
 This scheduling method runs tasks in a round-robin fashion. More...
 
def pri_sched (self)
 This scheduler runs tasks in a priority based fashion. 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

This class holds the list of tasks which will be run by the task scheduler.

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.

An example showing the use of the task list is given in the documentation for class Task.

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)

This scheduler runs tasks in a priority based fashion.

Each time it is called, it finds the next task which is ready to run and calls that task's run() method.

◆ rr_sched()

def cotask.TaskList.rr_sched (   self)

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. This scheduler runs the highest priority tasks first, but that's not important to a round-robin scheduler, as they are all 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: