5.2 Controlling Task Execution – Scheduling
5.2.1 Scheduling and Time Slicing Operations
As pointed out earlier, one of the primary jobs of the RTOS is to share out the processor time between the various tasks. This is defined to be task scheduling. To do this, the RTOS contains a function that decides when a task should run and for how long: the scheduler. Such decisions are based on a set of rules called a scheduling algorithm. Over the years, many algorithms have been developed; there's much to choose from. However, in practice, real-time systems use a very restricted set, ones that we'll look at shortly. First, though, let's revisit the topic of the runtime behavior of tasks, specifically their temporal aspects.
Consider the pressure control task shown in Figure 5.6(b) and its related pseudocode listing. We can model its time behavior using a state transition diagram, such as the one in Figure 5.11: