#define BASE_TIMESLICE(p) (MIN_TIMESLICE \ The task_timeslice()įunction is simply a call to theBASE_TIMESLICEmacro which is defined as: Static_prio value) the larger the timeslice it gets. The higher the task’s static priority (the lower the task’s Possi-ble timeslice range and making sure a certain minimum and maximum Timeslice is calculated by simply scaling a task’s static priority onto the Highly interactive task has a static priority of -20, it cannot be given a 5 pointīonus since it already has the maximum non-RT priority. Once a new dynamic priority has been calculated, the last thing thatĮf-fective_prio()does is within the non-RT priority range. Adding five is the maximum penalty a task’s priorityĬan get, which is the desired behavior for a CPU hog that never sleeps. Get set to -5 and the task’s static priority would get -5 subtracted from it, which If a task had asleep_avg of 0, itsĬURRENT BONUS(p) value might be 0. Sub-sequently, the task’s static priority would get 5 subtracted from it, which is ![]() ![]() If a task has a high sleep_avg andĬURRENT_BONUS(p)returns 10, then the bonus variable would be set to 5. Priority adjustment can be from 5 to -5), it is divided by two and that value Since MAX_BONUS is twice as largeĪs a task’s priority is allowed to rise or fall (MAX_BONUS of 10 means that the If a task has a high sleep_avg, the value returned byĬUR-RENT_BONUS will be high, and vice-versa. NS_TO_JIFFIES((p)->sleep_avg) * MAX_BONUS / MAX_SLEEP_AVG)Įssentially,CURRENT_BONUSmaps a task’s sleep average onto the range 0-MAX_BONUS, Theīonus = CURRENT_BONUS(p) - MAX_BONUS / 2 The function does not give bonuses or penalties to RT tasks. The first thing effective prio does is return a task’s current priority if it isĪ RT task. Modi-fied, sincesleep_avgis the primary heuristic for a task’s dynamic priority. In all cases, it is called after a task’ssleep_avg has been It is calledīy recalc_task_prio(), the thread and process wakeup calls, and Theeffective_prio()function calculates a task’s dynamic priority. Running time will offset the long sleep time. The Linux 2.6.8.1 scheduler’s interactivity heuristics prevent this because a long Sleep quite a while and still use up its timeslice, tasks that sleep for a long timeĪnd then hog a CPU must be prevented from getting a huge interactivity bonus. Is quite accurate since it keeps track of both how much time is spent sleepingĪs well as how much time is spent running. The higherĪ task’ssleep_avg is, the higher its dynamic priority will be. The current task spent running is subtracted from its sleep_avg. When a task gives up the CPU, voluntarily or involuntarily, the time Is added to itssleep_avgvariable (though a task’ssleep_avgis not allowed toĮxceedMAX_SLEEP_AVG for the sake of mapping sleep avg onto possible bonus Linux 2.6.8.1 scheduler, when a task is woken up from sleep, its total sleep time Sort of scale instead of a simple binary label (I/O-bound or CPU-bound). Quite often, tasks are in the middle,Īnd are not entirely CPU-bound or I/O-bound so the heuristic produces some Task rarely sleep as they rarely block on I/O. I/O-bound tend to sleep quite a bit as they block on I/O, whereas CPU-bound Sleeping (presumably blocked on I/O) as opposed to running. This heuristic is implemented by keeping track of how much time tasks spend ![]() Via thenice()system call, a relative adjustment will be made between the twoĭynamic priority bonuses and penalties are based on interactivity heuristics. If a user changes either’s static priority With a nice value of -2 might have a dynamic priority of 0, the same as a task ![]() Penalties, adjustments to a task’s static priority are respected. In the Linux 2.6.8.1 scheduler, the maximum priority bonus is 5Īnd the maximum priority penalty is 5. Sched-uler’s term for I/O bound), its priority is boosted. Pri-ority is called a task’s dynamic pripri-ority, and is accessible via the task’s prio Tasks by adding or subtracting from a task’s static priority. The Linux 2.6.8.1 scheduler rewards I/O-bound tasks and punishes CPU-bound Task,p->static_priois its static priority. Users can modify task’s priority, and the scheduler will respect the user’s inputĪ task’s static priority is stored in itsstatic_prio variable. Static priority is the mechanism through which Initial value and modifications via thenice() system call, the scheduler neverĬhanges a task’s static priority. Of 0, but that priority can be changed via thenice()system call. By default, tasks start with a static priority Range from -20 to 19, with higher values being lower priority (tasks with high 5.4.1 Static Task Prioritization and the nice()System CallĪll tasks have a static priority, often called anice value.
0 Comments
Leave a Reply. |