Start a process with a scheduling policy on Linux

Scheduling policy types and their descriptions are beyond the scope of this article. (It may be added later)

How to start a process with a scheduling policy

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···

Additional investigation

$ 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
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


Quiet talk

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.

  626 ec2-user  20   0  132m 7088 4304 R 49.8  0.7   7:53.42
  722 ec2-user  20   0  132m 6980 4196 R 49.8  0.7   3:45.94

Checking with the ps command, the CPU usage is biased as follows.

[[email protected] experiment]$ ps -C -o comm,pid,ppid,cls,rtprio,pri,ni,%cpu
COMMAND           PID  PPID CLS RTPRIO PRI  NI %CPU      626 26292  TS      -  19   0 69.1      722 26292  TS      -  19   0 35.4

Why··· Furthermore, it is a mystery that the total of% CPU exceeds 100.

Recommended Posts

Start a process with a scheduling policy on Linux
Run a Linux server on GCP
Create a Linux environment on Windows 10
PBR (Policy Base Routing) on Linux
Create a Docker container image with JRE8 / JDK8 on Amazon Linux
Building a Python3 environment with Amazon Linux2
Procedure for building a kube environment on amazon linux2 (aws) ~ (with bonus)
X86 assembler on Linux (linkage with C)
Build a simple WebDAV server on Linux
A memo with Python2.7 and Python3 on CentOS
[C] [python] Read with AquesTalk on Linux
Make Unity Accelerator a service on Linux
Throw a request with a certificate on httpie
Linux process
Build a CentOS Linux 8 environment with Docker and start Apache HTTP Server
Build a Samba server on Arch Linux
Install Mecab on Linux (CentOS) with brew
Run a batch of Python 2.7 with nohup on Amazon Linux AMI on EC2
[Linux] Build a jenkins environment with Docker
A note on enabling PostgreSQL with Django
Create a permanent write area on Kali Linux with USB memory boot
Create a Linux virtual machine on Windows
Run Linux on ARM architecture with QEMU
[Linux] Build a Docker environment with Amazon Linux 2
Start a temporary http server locally with Pytest
Build a WardPress environment on AWS with pulumi
Install Windows 10 from a Linux server with PXE
Try Tensorflow with a GPU instance on AWS
Open a ZIP created on Windows in Linux
Set up golang with goenv on GNU / Linux
Build a python environment with ansible on centos6
Start Django in a virtual environment with Pipenv
Start a simple Python web server with Docker
Organize files on Windows with Linux commands-using WSL-
A little advanced job scheduling with AP Scheduler
Try to create a new command on linux
Mount a directory on another server with sshfs
Decrypt a string encrypted on iOS with Python
Install PHP 7 series on Amazon Linux 2 with Amazon Linux Extras
Insert a fixed process after SELECT with SQLAlchemy
Visualize grib2 on a map with python (matplotlib)
Build a server on Linux and local network with Raspberry Pi NextCloud and desktop sharing
Run Kali Linux on Windows with GUI (without VirtualBox)
Specify the volume on linux and make a sound
Create a QR code for the URL on Linux
Yum command to access MySQL with Python 3 on Linux
How to install Linux on a 32bit UEFI PC
Make a breakpoint on the c layer with python
[Part 2] Let's build a web server on EC2 Linux
I made a Python3 environment on Ubuntu with direnv.
Set up Docker on Oracle Linux (7.x) with Vagrant
Looking back on creating a web service with Django 2
SoC FPGA: A small story when using on Linux
[Part 1] Let's set up a Minecraft server on Linux
A note on speeding up Python code with Numba
Deploy a Django app made with PTVS on Azure
Launch Django on a Docker container with docker-compose up
Unzip a ZIP file larger than 4GB on Linux.
Notes on creating a virtual environment with Anaconda Navigator
A story about a Linux beginner putting Linux on a Windows tablet
Making a paper craft on Linux/macOS with OSS Memo