The scheduler's entry point
The process of scheduling starts with a call to the generic scheduler, that is, the schedule()
function, defined in <kernel/sched/core.c>
. This is perhaps one of the most invoked routines in the kernel. The functionality of schedule()
is to pick the next best runnable task. The pick_next_task()
of the schedule()
function iterates through all the corresponding functions contained in the scheduler classes and ends up picking the next best task to run. Each scheduler class is linked using a single linked list, which enables the pick_next_task()
to iterate through these classes.
Considering that Linux was primarily designed to cater to highly interactive systems, the function first looks for the next best runnable task in the CFS class if there are no higher-priority runnable tasks in any of the other classes (this is done by checking whether the total number of runnable tasks (nr_running
) in the runqueue is equal to the total number of runnable tasks in the...