Presentation is loading. Please wait.

Presentation is loading. Please wait.

Linux Scheduler.

Similar presentations


Presentation on theme: "Linux Scheduler."— Presentation transcript:

1 Linux Scheduler

2 Scheduling in Linux: Prior to Version 2.5 Traditional Unix Scheduler
Processes Classes for Scheduling Purposes So-Called Real-Time are just high priority Priorities Real-time FIFO Non-preemptible Real-time round robin Preemptible if its quantum expires Timesharing Priorities 100 – 139 Did not support systems with multiple processors well

3 With Version 2.5 O(1) Scheduler
Ready queue organized as two chained hash-tables Active: ready/quantum has not expired Expired: ready/quantum has expired Each list within a category has a different priority and will receive a different size time slice Operation Select task from highest priority queue in Active list If it’s time slice expires, move it to the expired list If it blocks, decrement its time slice counter and put it back on the Active queue Priority is constantly recalculated Reward interactive processes Punish cpu-intensive processes Ran in constant regardless of the number of processes in the system. Had features that favored multiple processors like load balancing. Ran poorly on interactive systems

4 With Version 2.6 CFS(completely fair scheduler) Selecting Which Process to Run Next
Ready queue organized as a red-black tree Each internal node is a task Children on left had less time on CPU Children on right had more time on CPU Schedule task which had least amount of CPU time Selecting a node: O(N) because it’s the left-most node Inserting a node: O(lg(n)) because the tree is balanced Accounts for priorities virtual clock ticks more quickly for low priority processes virtual clock ticks more slowly for high priority processes

5 CFS Conventional (interactive processes) Setting Static Priority
Each interactive process has it own static priority: 100 (highest) – 139 (lowest) A new process inherits the static priority of its parent Determines the base time quantum in milliseconds according to this formula: if static priority < 120 base_time_quantum = (140 – static priority) * 20 else base_time_quantum = (140 – static priority) * 5 Since a higher process is associated with a lower numerical value, high priority processes start off with a longer quantum. Highest static priority is 100: btq = (140 – 100) * 20 = 800 ms Default static priority is 120: btq = (140 – 120) * 5 = 100 ms Lowest static priority is 139: btq = (140 – 139) * 5 = 5 ms Nice values: Older linux/unix systems used nice() which sets priorities from -20 to 19. These correspond 100 to 139

6 Conventional (interactive processes)
Dynamic Priority The priority used in making scheduling decisions dynamic_priority = max(100, min(static_priority – bonus + 5, 139)) Bonus [ ] < 5 is a penalty for bad behavior > 5 is a premium for good behavior Related to the average sleep time of the process. That is, if the process has blocked several times it has slept more than one that has blocked only once. It is more interactive Example static_priority = 130 (i.e., a low static priority) bonus = 10 (process behaved well) dynamic_priority = max(100, min(125, 139)) = 125


Download ppt "Linux Scheduler."

Similar presentations


Ads by Google