如何讓一個process擁有絕對優先權? - Linux

By Lauren
at 2019-01-04T21:32
at 2019-01-04T21:32
Table of Contents
最近又有時間搞這些有的沒有的了
而且還不小心成功了,所以就上來做個紀錄順便騙騙P幣
OS: Ubuntu 18.04
Kernel: 4.15.0-43-generic
首先得先在/etc/security/limits.conf裡新增底下這一行
YourUserName - rtprio 99
修改完後重新登入
這樣YourUserName這個帳號才有權限用chrt提高mpv的優先權
而不用每次都要sudo
再來直接用chrt執行mpv
$ chrt -r 99 mpv VIDEO_FILE
這樣mpv就能獲得極高的優先權
即便一邊build code一邊瀏覽網頁也不會掉幀
有一點蠻奇怪的就是一定要直接用chrt執行mpv
如果先開mpv再用chrt去調整mpv的優先權,例如:
$ mpv VIDEO_FILE &
$ chrt -r -p 99 $(pidof mpv)
調整就會無效,掉幀掉個不停
之前就都是用這樣的方式調整優先權
怎麼調都沒有反應,覺得這部份似乎有bug
另外build code可以用SCHED_IDLE這個scheduling policy,例如:
$ chrt -i 0 make -jN (N=number of jobs)
這個是Linux裡優先權最低的policy (但好像也只等同nice -n 20)
用了之後感覺比較不會影響到影片的播放(?
大概就是這樣,供大家參考~~~
※ 引述《idisnothing ()》之銘言:
: 如題
: 已經用renice把該程式的CPU優先權調為最高(-20)
: 但當編譯程式時 ($ nice -n 19 make -j 4),該程式還是會受到影響
: 有什麼方法可以讓一個process擁有絕對優先權嗎?
: 需要重新編譯核心嗎?
--
而且還不小心成功了,所以就上來做個紀錄順便騙騙P幣
OS: Ubuntu 18.04
Kernel: 4.15.0-43-generic
首先得先在/etc/security/limits.conf裡新增底下這一行
YourUserName - rtprio 99
修改完後重新登入
這樣YourUserName這個帳號才有權限用chrt提高mpv的優先權
而不用每次都要sudo
再來直接用chrt執行mpv
$ chrt -r 99 mpv VIDEO_FILE
這樣mpv就能獲得極高的優先權
即便一邊build code一邊瀏覽網頁也不會掉幀
有一點蠻奇怪的就是一定要直接用chrt執行mpv
如果先開mpv再用chrt去調整mpv的優先權,例如:
$ mpv VIDEO_FILE &
$ chrt -r -p 99 $(pidof mpv)
調整就會無效,掉幀掉個不停
之前就都是用這樣的方式調整優先權
怎麼調都沒有反應,覺得這部份似乎有bug
另外build code可以用SCHED_IDLE這個scheduling policy,例如:
$ chrt -i 0 make -jN (N=number of jobs)
這個是Linux裡優先權最低的policy (但好像也只等同nice -n 20)
用了之後感覺比較不會影響到影片的播放(?
大概就是這樣,供大家參考~~~
※ 引述《idisnothing ()》之銘言:
: 如題
: 已經用renice把該程式的CPU優先權調為最高(-20)
: 但當編譯程式時 ($ nice -n 19 make -j 4),該程式還是會受到影響
: 有什麼方法可以讓一個process擁有絕對優先權嗎?
: 需要重新編譯核心嗎?
--
Tags:
Linux
All Comments

By Noah
at 2019-01-08T20:09
at 2019-01-08T20:09

By John
at 2019-01-09T08:09
at 2019-01-09T08:09

By Isabella
at 2019-01-10T16:56
at 2019-01-10T16:56

By Tracy
at 2019-01-12T04:46
at 2019-01-12T04:46

By Poppy
at 2019-01-13T11:48
at 2019-01-13T11:48

By Vanessa
at 2019-01-18T07:48
at 2019-01-18T07:48

By Mason
at 2019-01-19T03:12
at 2019-01-19T03:12

By Donna
at 2019-01-19T22:25
at 2019-01-19T22:25

By Una
at 2019-01-23T08:17
at 2019-01-23T08:17

By Jacky
at 2019-01-25T11:33
at 2019-01-25T11:33

By Skylar DavisLinda
at 2019-01-25T13:11
at 2019-01-25T13:11

By Rebecca
at 2019-01-27T07:42
at 2019-01-27T07:42

By Ivy
at 2019-01-30T17:18
at 2019-01-30T17:18

By Linda
at 2019-02-02T19:31
at 2019-02-02T19:31

By Damian
at 2019-02-06T20:10
at 2019-02-06T20:10

By Enid
at 2019-02-08T19:41
at 2019-02-08T19:41

By Ina
at 2019-02-11T23:09
at 2019-02-11T23:09

By Bennie
at 2019-02-16T10:39
at 2019-02-16T10:39

By Bennie
at 2019-02-18T20:10
at 2019-02-18T20:10

By Victoria
at 2019-02-22T15:15
at 2019-02-22T15:15

By Catherine
at 2019-02-26T04:38
at 2019-02-26T04:38

By James
at 2019-03-02T10:34
at 2019-03-02T10:34

By Kama
at 2019-03-04T15:09
at 2019-03-04T15:09

By Selena
at 2019-03-07T03:36
at 2019-03-07T03:36

By Zenobia
at 2019-03-07T13:18
at 2019-03-07T13:18

By Doris
at 2019-03-11T15:48
at 2019-03-11T15:48

By Kumar
at 2019-03-14T16:27
at 2019-03-14T16:27

By Rebecca
at 2019-03-16T02:52
at 2019-03-16T02:52

By Brianna
at 2019-03-16T20:34
at 2019-03-16T20:34

By Ula
at 2019-03-18T13:33
at 2019-03-18T13:33

By Agnes
at 2019-03-22T00:25
at 2019-03-22T00:25

By Erin
at 2019-03-24T13:08
at 2019-03-24T13:08

By Regina
at 2019-03-25T20:28
at 2019-03-25T20:28
Related Posts
求救 ubuntu 16.04 selenium exception

By Lily
at 2018-12-29T18:13
at 2018-12-29T18:13
telegram-cli 中文輸入?

By Elma
at 2018-12-27T20:16
at 2018-12-27T20:16
無法安裝需要的套件?

By Genevieve
at 2018-12-27T12:40
at 2018-12-27T12:40
ubuntu 14.04 complie C 問題

By Liam
at 2018-12-27T11:29
at 2018-12-27T11:29
VLAN tag over Internet如何才能達成?

By Zanna
at 2018-12-27T01:21
at 2018-12-27T01:21