The kernel maintains a priority value (sometimes termed the scheduling priority) for each thread. The priority value is a positive integer and varies inversely with the importance of the associated thread. That is, a smaller priority value indicates a more important thread. When the scheduler is looking for a thread to dispatch, it chooses the dispatchable thread with the smallest priority value.
The recent CPU usage value of a given thread is incremented by 1 each time that thread is in control of the CPU when the timer interrupt occurs (every 10 milliseconds). The recent CPU usage value is displayed as the C column in the ps command output. The maximum value of recent CPU usage is 120.
The algorithm for calculating priority value uses the nice value
of the process to determine the priority of the threads in the process. As
the units of CPU time increase, the priority decreases with the nice
effect.
Using schedo -r -d
can give additional control over the priority
calculation by setting new values for R and D. See schedo command for
further information.
nice
value is greater than 20, then it has double
the impact on the priority value than if it was less than or equal to 20.
The new priority calculation (ignoring integer truncation) is as follows:
Comments
Post a Comment
https://gengwg.blogspot.com/