












Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!













CS 3210 Operating System Design Hutto, College of Computing, Georgia Tech
scheduler (policy) vs. dispatcher (mechanism) z
z
io schedulers: packet scheduler, disk scheduler z
goal: maximize CPU utilization z
real-world schedulers need to be general purpose z must meet many competing demands, job mixes z throughput, responsiveness, priorities, no starvation, …
CS 3210 Operating System Design Hutto, College of Computing, Georgia Tech
preemption z
z
z time-sharing z
z
blocking z termination z slice expires (check at timer interrupt) z higher priority process becomes runnable (preemption) z
CS 3210 Operating System Design Hutto, College of Computing, Georgia Tech
priority and fairness are antagonistic z Linux provides priorities but still tries to be fair z general rules: z decrease priority of processes that run a lot z increase priority of processes that sleep a lot z avoid starvation (aging) z boost "interactive" processes
CS 3210 Operating System Design Hutto, College of Computing, Georgia Tech
nice() z
z
z
increasing (+) nice decrease priority z decreasing (-) nice increases priority z get/setpriority() z sched_get/setscheduler() z sched_get/setparam() z sched_yield()
CS 3210 Operating System Design Hutto, College of Computing, Georgia Tech
how long? similar to timer interrupt frequency z too short – too much time spent switching z like "thrashing", spending too much time swapping z too long – processes feel unresponsive z you run longer but you also wait longer z priority, interrupts also increase response z 2.4 uses about 10 ticks (105 ms)
CS 3210 Operating System Design Hutto, College of Computing, Georgia Tech
higher priority than "regular" processes z can be created only by root z can disrupt system if poorly programmed z Windows has three levels: z regular, system, realtime z realtime processes have priority too (1-99) z so called "static priority" (though can be changed) z used to differentiate rt processes z always higher than regular process priorities
CS 3210 Operating System Design Hutto, College of Computing, Georgia Tech
nice – base quantum (-20 to +19) z counter – ticks remaining in quantum z rt_priority – 0 (regular) to 99 z policy - regular or realtime z SCHED_OTHER – regular z SCHED_FIFO – realtime, "run to completion" z SCHED_RR – realtime, quantum but no epoch z need_resched z processor, cpus_allowed, cpus_runnable z aligned_data – per-processor struct z curr – task_struct of current z last_schedule – TSC value of last process switch
CS 3210 Operating System Design Hutto, College of Computing, Georgia Tech
Direct invocation z when a process blocks in the kernel z sometime by device drivers to yield CPU z Lazy invocation z need_resched bit z checked on transition from kernel to user z on quantum expiration z for preemption (wakeup/creation of higher priority) z on sched_setscheduler() or sched_yield()
CS 3210 Operating System Design Hutto, College of Computing, Georgia Tech
goal: z set next to task_struct of next process z call switch_to(prev, next, prev) z acquire spinlock, disable interrupts toexamine runqueue z special case for exhausted SCHED_RRprocess z update state and need_resched
CS 3210 Operating System Design Hutto, College of Computing, Georgia Tech
iterate through tasklist (not runqueue!) z replenish quantum if expired z add to non-zero quanta of blocked processes z i/o boost (bounded)
CS 3210 Operating System Design Hutto, College of Computing, Georgia Tech
prev == next special case z update some kernel statistics z address space switch for kernel threads z invoke switch_to() z code after switch_to() executed when prev isrescheduled again in the future z uniprocessor – not much z multiprocessor – try to reschedule prev
CS 3210 Operating System Design Hutto, College of Computing, Georgia Tech
called in "tail" of schedule() on MP z tries to reschedule prev on another CPU z is last processor prev ran on idle? z what's the "oldest idle" processor? z is there a process with lower priority running? z uses IPI to initiate reschedule
CS 3210 Operating System Design Hutto, College of Computing, Georgia Tech
Looks like two processors z No special enhancements in 2. z Except when ht processor runs 2 idles z breaks the "oldest idle" rule in reschedule_idle() z 2.6 has more enhancements z hyper-threads not the same as real CPUs z probably dual-core enhancements coming