{"id":659,"date":"2021-03-10T11:40:06","date_gmt":"2021-03-10T17:40:06","guid":{"rendered":"https:\/\/vostorga.org\/?p=659"},"modified":"2021-03-10T11:40:06","modified_gmt":"2021-03-10T17:40:06","slug":"assigning-the-priority-of-services-during-the-boot-process","status":"publish","type":"post","link":"https:\/\/vostorga.org\/?p=659","title":{"rendered":"Assigning the priority of services during the boot process"},"content":{"rendered":"\r\n<p>Linux provides the following choices for Process Scheduling:<\/p>\r\n\r\n\r\n\r\n<ul class=\"wp-block-list\">\r\n<li>SCHED_FIFO: Static Priority scheduling<\/li>\r\n<li>SCHED_RR: round-robin variant of the <code>SCHED_FIFO<\/code><\/li>\r\n<li>SCHED_OTHER: default scheduling policy which uses the Completely Fair Scheduler (CFS)<\/li>\r\n<li>SCHED_BATCH: for &#8220;batch&#8221; style execution of processes<\/li>\r\n<li>SCHED_IDLE: for running very low priority background jobs<\/li>\r\n<\/ul>\r\n\r\n\r\n\r\n<p>Usually to check and assign policies we use the chrt command, for example:<\/p>\r\n\r\n\r\n\r\n<p><em><strong>Checking Current policy of PID 1012:<\/strong><\/em><\/p>\r\n\r\n\r\n\r\n<blockquote>\r\n<p><code># chrt -p 1012<br \/>pid 1012's current scheduling policy: SCHED_OTHER<br \/>pid 1012's current scheduling priority: 0<\/code><\/p>\r\n<\/blockquote>\r\n\r\n\r\n\r\n<p><em><strong>Assigning Policy FIFO with priority 50 to PID 1012:<\/strong><\/em><\/p>\r\n\r\n\r\n\r\n<blockquote>\r\n<p><code>#chrt -fifo -p 50 1-12\r\n# chrt -p 1012<br \/>pid 1012's current scheduling policy: SCHED_FIFO<br \/>pid 1012's current scheduling priority: 50<\/code><\/p>\r\n<\/blockquote>\r\n<!-- \/wp:group -->\r\n\r\n<!-- wp:paragraph -->\r\n<p>&nbsp;<\/p>\r\n<p>But if we want a service to always have the same Scheduling policy, we may modify systemd service file as follows:<\/p>\r\n<p><code>[Service]<br \/>....<br \/>CPUSchedulingPolicy=fifo<br \/>CPUSchedulingPriority=50<\/code><\/p>\r\n<!-- \/wp:paragraph -->\r\n\r\n<!-- wp:paragraph -->\r\n<p>Then reloading daemon\u00a0 (systemctl daemon-reload) and restarting service will show our service with new scheduling.<\/p>\r\n<p>&nbsp;<\/p>\r\n<!-- \/wp:paragraph -->","protected":false},"excerpt":{"rendered":"<p>Linux provides the following choices for Process Scheduling: SCHED_FIFO: Static Priority scheduling SCHED_RR: round-robin variant of the SCHED_FIFO SCHED_OTHER: default scheduling policy which uses the Completely Fair Scheduler (CFS) SCHED_BATCH: for &#8220;batch&#8221; style execution of processes SCHED_IDLE: for running very low priority background jobs Usually to check and assign policies we use the chrt command, [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[216,213,215,214,212],"class_list":["post-659","post","type-post","status-publish","format-standard","hentry","category-linux","tag-centos","tag-process","tag-redhat","tag-scheduling","tag-systemd"],"_links":{"self":[{"href":"https:\/\/vostorga.org\/index.php?rest_route=\/wp\/v2\/posts\/659"}],"collection":[{"href":"https:\/\/vostorga.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vostorga.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vostorga.org\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/vostorga.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=659"}],"version-history":[{"count":9,"href":"https:\/\/vostorga.org\/index.php?rest_route=\/wp\/v2\/posts\/659\/revisions"}],"predecessor-version":[{"id":668,"href":"https:\/\/vostorga.org\/index.php?rest_route=\/wp\/v2\/posts\/659\/revisions\/668"}],"wp:attachment":[{"href":"https:\/\/vostorga.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=659"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vostorga.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=659"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vostorga.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=659"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}