1

If we'll be running two or more than two processes in the same cpu core then preemption is being done by kernel because the Vruntime of the running process will exceed some threshold value and hence process with next shortest vruntime will get cpu.

Is there any way to calculate this threshold value?How Linux kernel calculate this value for scheduling being completely fair (CFS)?

Scissor
  • 153
  • 2
  • 14
  • Did you try reading the Linux scheduler code? That will be the only way to know for sure how it works. – Zan Lynx Mar 04 '15 at 17:30
  • yes, I was reading but couldn't find any function where this value has been calculated. Moreover, I performed various experiments and was getting different values for this threshold for different types of programs. Means it seems this value is not constant. Correct me if I'm wrong. – Scissor Mar 04 '15 at 17:57
  • I don't think the value you're asking about exists in the code, as such. I seem to remember something about process runtime vs total CPU time and virtual clocks. – Zan Lynx Mar 04 '15 at 18:19
  • 1
    IIRC this value is not a constant, anyway... It involves the processes "nice" value, it's current priority, whether or not it used it's entire time slice last time it was scheduled, whether it was pre-empted or slept for I/O or other activities, and probably a few other factors. Based on those factors, as well as some system-wide ones (HZ, current load, cgroup and rlimit constraints, ....), a maximum timeslice is assigned for this "turn". But it might be completely different on the next "turn"... – twalberg Mar 04 '15 at 19:02
  • Probably you are looking for [sched_rr_get_interval()](http://linux.die.net/man/2/sched_rr_get_interval). See also this [answer](http://stackoverflow.com/a/16402758/3866447). – Sam Protsenko Mar 04 '15 at 20:04

0 Answers0