

Task Scheduler in Real-time OSes (Part 2)
Define OS Scheduling based on methodologies such as Timeslice/Priority
Overview#
This article is part 2 of an overview series specifically about the Scheduler in a Real-time Operating System (RTOS). Examples of such systems can be found in almost anything from automotive application such as airbags, emergency breaks to avionics, and also infotainment, multi-media systems like video playback and QoS in web servers.
Read Part 1: Task Scheduler in RTOS
Static Scheduling#
As mentioned, predictability for an RTOS is an important characteristic and Static Scheduling provides just that, the ability to schedule, optimize for the tasks at runtime with very low complexity. Although, this also means that every modification requires execution of the scheduling algorithm again.
Taxonomy of Static Scheduling binded with Priority Scheduling Scheme. Different methodologies include timeslice, periodicity, and priority
For Static Scheduling, all parameters of all the tasks are assumed knownn in which the Scheduler built a schedule based on this information. This characterstic makes it simplier to schedule by timeslice based on task arrival pattern since there will be no change throughout the schedules.
Clock-Driven Scheduling#
Clock-Driven Scheduling is a Static Scheduling mechanism that consist of the following characteristics:
- Schedule is created off-line at compile time
- Precedence is treated explicitly between tasks
- Scheduler operates when timer expires, i.e. Timer interrupt
Following is example of Clock-Driven Scheduling with a timeslice of Scheduling time and three tasks , , scheduled at compile time.
Task () | Period () | Execution Time () | Deadline () |
---|---|---|---|
3 | 1 | 3 | |
4 | 1 | 4 | |
10 | 2 | 10 |
Table of Schedule for 3 Tasks with their Execution Time, Period and Deadline
Before any scheduling, a concept of CPU Utilization is important since tasks with fast period and long execution time will occupy a large amount of CPU resources.
CPU Utilization is defined as the sum of all tasks’ Execution times divided by their Periods . If the sum is greater than 1, then the system is guaranteed not feasible.
For this example of 3 Tasks, , and thus the system will not be unfeasible. It does not mean the system is feasible yet, this point will be discussed in the schedule plot.
On the following plot, the Scheduler generates and allocates Tasks with start-of-task one direction arrow () and end-of-task small dot (.) at the end of Execution Time (filled range).
Task , , and Processor plotted on Scheduling time (t) x-axis in 20 seconds
- On the first line of Task 1, the timer interrupts the system at time 0 and is selected. The job of is then executed through out its and come to a stop at then the next task is up.
- Side note: similarly the second and third lines of Task 2 and 3 respectively.
- Since start-of-task is , it takes control next.
- Side note: there is no concept of priority yet, the only determinants are which Task available and ready.
- At time , the Scheduler selects eventhough also starts at . That is because Task 3 Period is and thus not executed until the next timeslice .
Acknowledgement#
This series is heavily influenced by a Coursera online course ↗ created by the EIT-Digital University in Turku, Finland as part of the on-campus course on Real-Time Systems given in their Embedded Systems Master’s curriculum.