1 Understanding process scheduling timing and process switching processes:
-
Schedule () calls occur during interrupt processing (including clock interrupts, I/O interrupts, system calls, and exceptions), call schedule () directly, or call schedule () from the need_resched tag when returning to the user state;
- Kernel threads can directly call schedule () for process switching, or in the process of interrupt processing, which means that kernel threads as a special kind of process can be active scheduling, but also can be passively dispatched;
- The user-state process cannot implement the active scheduling, but can only be dispatched by a point in time after the kernel state, that is, scheduling during interrupt processing.
Analyze a schedule () function to verify your understanding of Linux system process scheduling and process switching process, and recommend to complete the experiment in the lab Building Linux virtual Machine environment.
Switch_to prev points to the current process, and next points to the scheduled process. Switching mechanism of the process context:
Interrupt Context Switch relationship: Before and after the interrupt is in the same process context, only by the user state to the kernel state execution. Switch_to is a function that indicates the content of the next specific instruction to be executed.
Timing of process scheduling and timing of process switching scheduling: Occurs during interrupt processing, such as I/O interruption, clock interrupt, etc., or in the execution of the return user state is called schedule ().
The switch_to stack state is processed at the save site of the currently executing process x content, and then restore_all the contents of the process Y that is about to be executed. Summary part: Linux system General execution process, can be abstracted into the executing process x switch to process y and then switch to process Z ... And so on, between the various states to be involved in the preservation of the scene, the resumption of the scene, the context of the switch, there are a series of process scheduling timing, algorithm selection, and so on, is the core of the computer is a key part of a very central part.
Process scheduling and process switching in the process scheduling and tracking analysis