Data Structures

The scheduler uses a series of data structures to sort and manage the processes in the system. How the scheduler works is closely linked with the design of these structures. Several components interact with each other in many ways, and Figure 2-13 provides a first overview of the connections.

Scheduling can be activated in two ways: either directly if a task goes to sleep or wants to yield the CPU for other reasons, or by a periodic mechanism that is run with constant frequency and that checks from time to time if switching tasks is necessary. I denote these two components generic scheduler or core se scheduler in the following. Essentially, the generic scheduler is a dispatcher that interacts with two other components:

1. Scheduling classes are used to decide which task runs next. The kernel supports different scheduling policies (completely fair scheduling, real-time scheduling, and scheduling of the idle task when there is nothing to do), and scheduling classes allow for implementing these policies in a modular way: Code from one class does not need to interact with code from other classes.

When the scheduler is invoked, it queries the scheduler classes which task is supposed to run next.

2. After a task has been selected to run, a low-level task switch must be performed. This requires close interaction with the underlying CPU.

Figure 2-13: Overview of the components of the scheduling subsystem.

Every task belongs to exactly one of the scheduling classes, and each scheduling class is responsible to manage their tasks. The generic scheduler itself is not involved in managing tasks at all; this is completely delegated to the scheduler classes.

Continue reading here: Elements in the Task Structure

Was this article helpful?

0 0