LoginSignup
1
1

More than 5 years have passed since last update.

CFSのvruntimeの状態遷移(メモ)

Posted at

CFSのvruntimeの挙動、ど忘れしたので、メモ。このメモ書きはCFSのvruntimeの挙動だけしか書いていません。それ以外の箇所(rbtreeやそもそもの仕様)には特に言及しません。

大体の感じ

以下の図の通り。厳密な図ではありません。よって、いくつか抜けはありますが、大筋を理解する分には問題ないと思います。

vruntime.png

スレッドがfork()されるときに、schedule entityのvruntimeが0に初期化され、その後、cfs queueに突っ込まれます。
このとき、突っ込まれたcfs queue内にあるschedule entityのvruntime最小値(min_vruntime)が足されます。cfs queueにschedule entityを突っ込むときにこれを足すことで、「vruntimeが最小となるスレッドが実行スレッドに選ばれる」CFSの仕様を実現できます。

update_curr()によって、実行状態スレッドのvruntimeが更新されます。スレッド実行時間(delta_exec = now - curr->exec_start;)に諸々を加味した値をvruntimeに足します。

schedule entityがcfs queueから抜かれるとき、vruntimeからmin_vruntimeを引きます。min_vruntimeはあくまでも「該当するcfs queueにとってのみ」意味のある値だからです。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1