Scheduling policy types and their descriptions are beyond the scope of this article. (It may be added later)
Use the chrt command. Specify FIFO with -f.
$ sudo chrt -f 38 yes > /dev/null &
Policy confirmation.
$ sudo chrt -p 32407
pid 32407's current scheduling policy: SCHED_OTHER
pid 32407's current scheduling priority: 0
Then, it is SCHED_OTHER. Why···
$ sudo chrt -f 1 yes > /dev/null &
The scheduling policy displayed by chrt -p and the scheduling policy displayed by cls of the ps command are different. (FF should be SCHED_FIFO)
$ ps -C yes -o comm,pid,ppid,cls,rtprio,%cpu
COMMAND PID PPID CLS RTPRIO %CPU
yes 27629 27628 FF 1 94.2
$
$ chrt -p 27629
pid 27629's current scheduling policy: SCHED_OTHER
pid 27629's current scheduling priority: 0
Why···
The following two processes running the same program (1) The process in which the SCHED_FIFO process is changed to SCHED_OTHER by chrt. (2) SCHED_OTHER process
Looking at the output of top, both have about the same CPU usage.
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
626 ec2-user 20 0 132m 7088 4304 R 49.8 0.7 7:53.42 cpu_bound.py
722 ec2-user 20 0 132m 6980 4196 R 49.8 0.7 3:45.94 cpu_bound.py
Checking with the ps command, the CPU usage is biased as follows.
[ec2-user@ip-172-21-0-185 experiment]$ ps -C cpu_bound.py -o comm,pid,ppid,cls,rtprio,pri,ni,%cpu
COMMAND PID PPID CLS RTPRIO PRI NI %CPU
cpu_bound.py 626 26292 TS - 19 0 69.1
cpu_bound.py 722 26292 TS - 19 0 35.4
Why··· Furthermore, it is a mystery that the total of% CPU exceeds 100.
Recommended Posts