04 Process.scheduling

Embed Size (px)

DESCRIPTION

Process Scheduling ppt

Citation preview

CSE 457/857 Systems Administration

CSE 457/857Systems AdministrationUNIX Process SchedulingUNIX Process Scheduling

UNIX Process SchedulingProcess is selected from runnable queue and begins executionExecution continues until:End of allowed time (timeslice/quanta)Process blocks syscall (before end of timeslice)Hardware interrupt occursCurrent process (user table) is swapped outOS selects another process to execute from the runnable queueSelection process is called scheduling algorithm

UNIX Process SchedulingSchedulingWhat is the goal?To make the system more usableEfficiency or Responsiveness?Average wait or turnaround?What process facilitates process scheduling?I/O bound vs CPU bound?UNIX Process SchedulingThe easy buttonFirst Come First Serve (FCFS)First In First Out (FIFO)O(1)AdvantagesFast!Simple, easy to implementIs this algorithm fair?Is starvation possible? If so, what kinds of jobs will typically be starved?How could starvation be mitigated?Does FIFO lead to a responsive system?UNIX Process SchedulingShortest Job First (SJF)Pick jobs that will need the least amount of CPU time firstWill this favor interactive jobs or batch jobs?How can the OS determine CPU need?O(n)Better than FIFO?If so, how is it better?Is starvation possible?What about scale?UNIX ProcessesSingle queue O(n)2.2.xList iterated on each sched()Kernel chooses process to run by goodness metricPriority considerationsProcess Group (PGID)Interactive vs Batch (SJF)Process ageAnd other assorted black magic

UNIX Process SchedulingMultiple O(1) queues2.4.x (2001)DrawKernel space code can now be preempted!What kind of service does this feature allow Linux to offer?SCHED_FIFOHow to use SCHED_FIFO? chrtAdvantages?Disadvantage?UNIX Process SchedulingDoes the system administrator have any control over process priority?Yes, by use of nice facilityDemoUNIX Processes SchedulingContinuous Fair Scheduler (CFS)>2.6.23 - ~2007O(1)New approach rad!Instead of prioritizing process based on predictive analysis, attempt to give each process a fair-share of CPU (avoid starvation) and maintain responsivenessBasic algorithmExecute task with lowest CPU run timeLet run for an arbitrary amount of timeOr process blocksWhen ready, reinsert into queuehttp://www.ibm.com/developerworks/library/l-completely-fair-scheduler/UNIX Process SchedulingContinuous Fair SchedulerQueue is a binary treeRed-black treehttps://en.wikipedia.org/wiki/Red-black_treeProcess selected is left-most (smallest aggregate runtime)No quanta/timesliceTime allowed to run based on system load ORIf aggregate runtime is greater than left-most elementnice is still available, implemented as decayA multiplier to aggregate runtime

UNIX Process SchedulingSCHED_FIFOScheduling policy designed for special time-critical applications. It uses the First In-First Out scheduling algorithm. SCHED_BATCHScheduling policy designed for CPU-intensive tasks. SCHED_IDLEScheduling policy intended for very low prioritized tasks. SCHED_OTHERDefault Linux time-sharing scheduling policy used by the majority of processes. SCHED_RRSimilar to SCHED_FIFO, but uses the Round Robin scheduling algorithm.

UNIX Process Schedulinghttps://www.youtube.com/watch?v=d3kfEeMZ65c