CS241 System Programming CPU Scheduling (2)ContentAdministrativePreemptive vs. Non-preemptiveWhat are the scheduling objectives?Scheduling ObjectivesPerformance CriteriaDifferent Systems, Different FocusesProcess ProfilesProgram Behaviors Considered in SchedulingCPU SchedulerDispatcherSingle Processor Scheduling AlgorithmsFirst Come First Serve (FCFS) (Batch Scheduling Policy)FCFS ExampleProblems with FCFSFCFS PerformanceConvoy EffectsPriority Scheduling (Interactive Scheduling Policy)Set PriorityPriority Scheduling: ExampleRound-robin (Interactive Scheduling Policy)Round-robin: ExampleTime QuantumSummaryCS241 System Programming CPU Scheduling (2)Klara NahrstedtLecture 112/13/200601/14/19 CS 241 - System Programming,Klara Nahrstedt2ContentBasic Scheduling Algorithm (FCFS)Round RobinPriority SchedulingSummary01/14/19 CS 241 - System Programming,Klara Nahrstedt3AdministrativeMP2 posted today, due February 27MP1 due today, February 13Read T: 2.4Quiz 3 will be on Friday, February 17, 2006Quiz 3 will include material from Tanenbaum, 3rd edition, section 2.2, 2.3, 2.4 AND LECTURE NOTES (see lecture note files)–lec6-syn1–lec7-syn2–lec8-syn3–lec8-syn4–lec10-sched–lec11-sched01/14/19 CS 241 - System Programming,Klara Nahrstedt4Preemptive vs. Non-preemptiveNon-preemptive scheduling:–The running process keeps the CPU until it voluntarily gives up the CPU process exitsswitches to blocked state1and 4 only (no 3)Preemptive scheduling:–The running process can be interrupted and must release the CPU (can be forced to give up CPU)RunningTerminatedReady Blocked14301/14/19 CS 241 - System Programming,Klara Nahrstedt5What are the scheduling objectives?(CPU (horsepower))Process 1Process 2 Process 3I want to ride itWhose turn is it?01/14/19 CS 241 - System Programming,Klara Nahrstedt6Scheduling ObjectivesFair (nobody cries)Priority (lady first)Efficiency (make best use of equipment)Encourage good behavior (good boy/girl)Support heavy loads (degrade gracefully)Adapt to different environments (interactive, real-time, multi-media)01/14/19 CS 241 - System Programming,Klara Nahrstedt7Performance CriteriaFairness Efficiency: keep resources as busy as possible Throughput: # of processes that completes in unit time Turnaround Time (also called elapse time)–amount of time to execute a particular process from the time its entered Waiting Time –amount of time process has been waiting in ready queue Response Time –amount of time from when a request was first submitted until first response is produced. –predictability and variance Policy Enforcement:– seeing that stated policy is carried out Proportionality: –meet users' expectation Meeting Deadlines: avoid losing data01/14/19 CS 241 - System Programming,Klara Nahrstedt8Different Systems, Different FocusesFor all–Fairness, policy enforcement, resource balanceBatch Systems–Max throughput, min turnaround time, max CPU utilization Interactive Systems–Min Response time, best proportionality Real-Time Systems–predictability, meeting deadlines01/14/19 CS 241 - System Programming,Klara Nahrstedt9Process ProfilesI/O – Bound –Does too much I/O to keep CPU busyCPU – Bound–Does too much computation to keep I/O busyProcess Mix–Scheduling should load balance between I/O bound and CPU-bound processes–Ideal would be to run all equipment at 100% utilization but that would not necessarily be good for response time01/14/19 CS 241 - System Programming,Klara Nahrstedt10Program Behaviors Considered in SchedulingIs it I/O bound? Example?Is it CPU bound? Example?Batch or interactive environment Urgency Priority Frequency of page faults Frequency of preemption How much execution time it has already received How much execution time it needs to complete compute computeI/OI/O I/O01/14/19 CS 241 - System Programming,Klara Nahrstedt11CPU SchedulerProc 1: 14 time unitsProc2: 8 time unitsProc3: 8 time unitsDispatcherPreemptive vs.non-preemptiveReady queueProc 1Proc 2Proc 3Proc 10Proc 11Proc 12blocked queueCPUDispatcher01/14/19 CS 241 - System Programming,Klara Nahrstedt12DispatcherGives the control of the CPU to the process, scheduled by the short-term scheduler. Functions: –switching context–switching to user mode–jumping to the proper location in the user program. Dispatch Latency :time to stop process and start another one. –Pure overhead–Needs to be fast01/14/19 CS 241 - System Programming,Klara Nahrstedt13Single Processor Scheduling AlgorithmsBatch systems–First Come First Serve (FCFS)–Short Job FirstInteractive Systems–Round Robin–Priority Scheduling–Multi Queue & Multi-level Feedback–Shortest process time–Guaranteed Scheduling–Lottery Scheduling–Fair Sharing Scheduling01/14/19 CS 241 - System Programming,Klara Nahrstedt14First Come First Serve (FCFS)(Batch Scheduling Policy)Process that requests the CPU FIRST is allocated the CPU FIRST. Also called FIFONon-preemptiveUsed in Batch Systems Real life analogy: Fast food restaurantImplementation: FIFO queues– A new process enters the tail of the queue–The schedule selects from the head of the queue. Performance Metric: Average Waiting Time. Given Parameters: –Burst Time (in ms), Arrival Time and Order01/14/19 CS 241 - System Programming,Klara Nahrstedt15FCFS ExampleProcess Duration Order Arrival TimeP1 24 1 0P2 3 2 0P3 4 3 0The final schedule:0P1 (24)24 27P2 (3) P3 (4)P1 waiting time: 0P2 waiting time: 24P3 waiting time: 27The average waiting time: (0+24+27)/3 = 1701/14/19 CS 241 - System Programming,Klara Nahrstedt16Problems with FCFSNon-preemptiveNot optimal AWTCannot utilize resources in parallel:–Assume 1 process CPU bounded and many I/O bounded processes –result: Convoy effect, low CPU and I/O Device utilization –Why?01/14/19 CS 241 - System Programming,Klara Nahrstedt17FCFS PerformanceWhat is the impact of convey effect?a) Slows down CPU bound processes?b) Slows down I/O bound processes?c) Low CPU utilization? d) Low I/O device utilization?e) All of the above?01/14/19 CS 241 - System Programming,Klara Nahrstedt18Convoy EffectsConsider n-1 jobs in system that are I/O bound and 1 job that is CPU bound. I/O bound jobs pass quickly through the ready queue and suspend themselves waiting for I/O. CPU bound job arrives at head of queue and
View Full Document