CPUProcess Scheduling Policy
For Real Time Scheduling #Real-time process
Sched_rr
# Search
Round-robin fashion, each process gets a max CPU time
Sched_fifo
# Queue, first-in-first-out
# This is what I keep occupying. You can use the CPU only after I finish it. However, if the process has serious I/O latency, the system will automatically call another one. Or the process uses the sched_yield function to separate the CPU from each other for a period of time. Or it is replaced by a high-priority process.
Runs until blocked by I/O, callsched_yield or preempted by a higher priority process
For general scheduling #Common non-real-time process
Sched_normal
For general applocations, standard round-robin Policy
Sched_batch
# This is special. It is a process for batch processing operations. For example, compress and merge data. It cannot be interrupted and runs for a long time. If this policy is applied, the CPU will take care of these processes accordingly.
For batch style process, tuned to not be preempted TPP often, tacks run longer,
Make Bette use of caches
Sched_idle
# This is for those nice whose number is smaller than 19 [This 19 is the smallest]
For low priority applications, with a very low priority (lower than Nice 19)
Test:
[[Email protected] ~] # Lscpu
Architecture: x86_64
CPU op-mode (s): 32-bit, 64-bit
Byte order: little endian
CPU (s): 2
On-line CPU (s) List: 0, 1
Thread (s) per core: 1
Core (s) per socket: 1
CPU socket (s): 2
NUMA node (s): 1
Vendor ID: genuineintel
CPU family: 6
Model: 13
Stepping: 3
CPU MHz: 2294.786
Bogomips: 4589.57
Hypervisor vendor: KVM
Virtualization type: full
L1d cache: 32 K
L1i cache: 32 K
L2 cache: 4096 K
NUMA node0 CPU (s): 0, 1
We have two CPUs, so we need to fill up the two CPUs for testing.
UseFIFOScheduling Algorithm:
[[Email protected] ~] # CHRT-f 10 top
It can be seen from the listed information that the top priority is still relatively high.
But after running the following command:
[[Email protected] ~] # CHRT-F 1 md5sum/dev/Zero &
[1] 1885
[[Email protected] ~] # CHRT-F 1 md5sum/dev/zero
It is found that the md5sum commands occupy the highest CPU priority and are always higher than the top two commands.
Then run:
[[Email protected] ~] # CHRT-R 1 sha1sum/dev/zero
In the top command, we cannot see that the sha1sum process is scheduled by the CPU.
Use the search scheduling algorithm:
[[Email protected] ~] # CHRT-R 1 md5sum/dev/Zero &
[1] 1885
[[Email protected] ~] # CHRT-R 1 md5sum/dev/zero
Then run:
[[Email protected] ~] # CHRT-R 1 sha1sum/dev/zero
It can be found that three processes have been scheduled by the CPU.
CPU process scheduling policy