ME 405 Romi
Loading...
Searching...
No Matches
cotask.TaskList Class Reference

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

Public Member Functions

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

Public Attributes

list pri_list = []
 The list of priority lists.

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.

Definition at line 299 of file cotask.py.

Constructor & Destructor Documentation

◆ __init__()

cotask.TaskList.__init__ ( self)

Initialize the task list.

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

Definition at line 303 of file cotask.py.

Member Function Documentation

◆ __repr__()

cotask.TaskList.__repr__ ( self)

Create some diagnostic text showing the tasks in the task list.

Definition at line 379 of file cotask.py.

◆ append()

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

Definition at line 316 of file cotask.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pri_sched()

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.

Definition at line 360 of file cotask.py.

◆ rr_sched()

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.

Definition at line 347 of file cotask.py.

Member Data Documentation

◆ pri_list

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.

Definition at line 309 of file cotask.py.


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