60 likes | 227 Views
Demo - Cooperative Scheduler. Thomas Patten Advanced Embedded Systems Monday, September 27, 2004. Scheduler Operation. Initialize Scheduler Clear the Memory Set up the Timer Initialize the task Add tasks to scheduler Done using an Array of Structures Start the Scheduler
E N D
Demo - Cooperative Scheduler Thomas Patten Advanced Embedded Systems Monday, September 27, 2004
Scheduler Operation • Initialize Scheduler • Clear the Memory • Set up the Timer • Initialize the task • Add tasks to scheduler • Done using an Array of Structures • Start the Scheduler • Run the Dispatcher • Check to see if any tasks need to be run • Update on Timer Overflow • Return to Dispatcher
struct name { type name; type name; } variable; struct stuff { char c; int n; }mystuff, hisstuff; hisstuff.c = ‘Y’; hisstuff.n = 199; Structures
Task Overlap • SCH_Add_Task(TaskA, 0, 1000) • SCH_Add_Task(TaskB, 0, 3000) • Every 3 seconds, the tasks will run at the same time, this is fixed using offsets • SCH_Add_Task(TaskA, 0, 1000) • SCH_Add_Task(TaskB, 5, 3000)
Tick Interval/Task Duration • All tasks should have a duration less than the tick interval! • Task Timeout should be used to prevent blocking the scheduler • Tick Interval should be set to the Greatest Common Factor for precise scheduling • Total time required to execute all scheduled tasks must be less than the processor time