Target of process scheduling:
1. Efficiency: efficiency means completing more tasks at the same time. SchedulingProgramWill be executed frequently, so the scheduling program should be as efficient as possible.
2. Enhance the interaction ability (interactivity): ensure the system response time under a considerable load of the system.
3. ensure fairness and avoid hunger and thirst.
4. SMP scheduling: The scheduler must support multiple processing systems. The system must track which processes are running on which CPU. Make sure that a process cannot run on more than one CPU at a time.
5. Soft Real-Time Scheduling (soft real-timescheduling): The system must effectively call real-time processes.
Nice value of the process:
The nice value is an attribute of each process. It is not the priority of the process, but a number that can affect the excellent static level first,-20 ~~ The default value is 0. The current kernel no longer stores nice values. Replace it with static_prio (static priority ). Nice values are visible to users. Static priorities are hidden in the kernel. Nice values and static priorities can be converted through a certain relational process. So nice only affects the static priority. For general processes, the dynamic priority is calculated based on the Static Priority: static_prio = max_rt_prio + nice + 20
Example: PS-El command execution result: the nice value of each process is displayed in the Ni column, and PRI is the priority of the process.
Non-real-time process priority:
1. Static Priority: static priority: it is called a static priority because it does not change over time, the kernel does not modify it, and can only be modified by calling nice.
2. Dynamic Priority: The scheduler rewards I/o Small processes or punishes CPU-consuming processes by increasing or decreasing the static priority of processes. The adjusted priority is a dynamic priority. Prio is used in the process descriptor,Generally, priority refers to dynamic priority.. From 0 ~ Value Between MAX_PRIO-1 (This is to be verified,Max_prio is defined as 140), where 0 ~ MAX_RT_PRIO-1 (max_rt_prio defined as 100) is within the scope of Real-Time Processes, max_rt_prio ~ MX_PRIO-1 is a non-real-time process. The greater the value, the smaller the process priority.
The priority of a common process is calculated by a function relation between the static priority and the interaction between processes. It is obtained according to the actual running status of the task. The real-time priority is linear with its real-time priority and does not change as the process runs.
Real-time process priority:
Real-time priority can be classified into sched_fifo and sched_rr, which can be soft, real-time, hard, and real-time. Both FIFO and RR are static priorities. In the process descriptor rt_priority. As mentioned above, the value ranges from 0 ~ MAX_RT_PRIO-1.
References: Linux kernel design and implementationModern Operating System