Reputation: 1753
In CFS scheduler, it always picks a process with minimum vruntime. vruntime of a running process is increased by the amount of CPU it consumes.
I have following two questions related to CFS and vruntime.
When multiple processes/threads are newly created, what is the initial vruntime of newly created process/thread ? Is the minimum vruntime in that ready queue at that time of creation or something else ?
If one process is there which has already ran for long and its vruntime is already high, in that scenario a new process is created. Now what will be the initial vruntime of newly created process ( keeping is mind the maximum unfairness ).
Upvotes: 3
Views: 305
Reputation: 3
The CFS scheduler uses an rbtree as it runqueue, so the leftmost node has the lowest vruntime and will be scheduled next. If you put a new process in that tree, you have to make content fairly with the others. This is done by setting it's vruntime on the creation to the lowest vruntime in the tree. CFS tracks that number in its struct as rq->cfs.min_vruntime
As the documentation states:
CFS also maintains the rq->cfs.min_vruntime value, which is a monotonic increasing value tracking the smallest vruntime among all tasks in the runqueue. The total amount of work done by the system is tracked using min_vruntime; that value is used to place newly activated entities on the left side of the tree as much as possible.
Upvotes: 0