[Linux kernel] CFS scheduler ④ (scheduling subsystem component module | main scheduler, periodic scheduler | scheduler class)





1. Scheduling subsystem component module



The scheduler needs to sort and schedule the scheduled processes ,

The process management process needs the component modules of the scheduler and related algorithm data structures to complete, such as: execution queue;

insert image description here





Second, the main scheduler, periodic scheduler



CPU selects "main scheduler" or "periodic scheduler" through "context switch ",


"Context switching" is mostly done

  • switch address space,
  • toggle register,
  • switch stack space

Work ;


The "main scheduler" completes the scheduling and switching of the process by calling the schedule()method ;


The "periodic scheduler" automatically calls the function according to the corresponding frequency to complete the scheduling, which is based on the running time of the process, which automatically triggers the process scheduling;scheduler_tick()





3. Scheduler class



The main scheduler or periodic scheduler selects different scheduler classes according to different "selected processes". For optional scheduling classes, refer to [Linux Kernel] Scheduler ⑦ (Scheduler Type | Stop Scheduling Class stop_sched_class | Deadline Scheduling Class dl_sched_class | Real-time scheduling | Fair scheduling | Idle scheduling) blog, in the Linux kernel, the sched_classscheduler is divided into the following 5 55 types:

  • stop_sched_class : stop scheduling class;
  • dl_sched_class : Deadline scheduling class;
  • rt_sched_class : real-time scheduling class;
  • fair_sched_class : fair scheduling class;
  • idle_sched_class : idle scheduling class;

Each scheduler class is responsible for scheduling and managing several processes,

The scheduler class is used to determine which process to run next,


insert image description here

Guess you like

Origin blog.csdn.net/han1202012/article/details/123846259