nice値の設定

参考:NICE, GETPRIORITY

getpriority()を使用したプライオリティの取得

nice()を使用したプライオリティの設定

setpriority()を使用したプライオリティの設定

ソースコード

実行結果

$ sudo ./getprio
[sudo] ***** のパスワード:
priority = 0

priority = -1

priority = 1

別ターミナルから確認

$ cat /proc/`pidof getprio`/sched | grep -e policy -e prio
getprio (105166, #threads: 1)
policy                                       :                    0
prio                                         :                  120
$ cat /proc/`pidof getprio`/stat | awk -F' ' '{print $18,$19}'
20 0

※ priority を -1 に設定後、確認

$ cat /proc/`pidof getprio`/sched | grep -e policy -e prio
getprio (105166, #threads: 1)
policy                                       :                    0
prio                                         :                  119
$ cat /proc/`pidof getprio`/stat | awk -F' ' '{print $18,$19}'
19 -1

※ priority を 1 に設定後、確認

$ cat /proc/`pidof getprio`/sched | grep -e policy -e prio
getprio (105166, #threads: 1)
policy                                       :                    0
prio                                         :                  121
$ cat /proc/`pidof getprio`/stat | awk -F' ' '{print $18,$19}'
21 1
$

設定値(CFSクラス)一覧

優先度/proc/<pid>/sched/proc/<pid>stat
prioprioritynice
高い1000-20
11919-1
デフォルト120200
121211
低い1393919

トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS