DOC PREVIEW
Pitt CS 1550 - CPU scheduling

This preview shows page 1-2-15-16-17-32-33 out of 33 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 33 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 33 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 33 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 33 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 33 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 33 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 33 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 33 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Slide 1Slide 2Slide 3Slide 4Slide 5Slide 6Slide 7Slide 8Slide 9Slide 10Slide 11Slide 12Slide 13Slide 14Slide 15Slide 16Slide 17Slide 18Slide 19Slide 20Slide 21Slide 22Slide 23Slide 24Slide 25Slide 26Slide 27Slide 28Slide 29Slide 30Slide 31Slide 32Slide 331CPU SchedulingCPU SchedulingScheduling the processor among all ready processesThe goal is to achieve: High processor utilizationHigh throughputnumber of processes completed per of unit timeLow response timetime elapsed from the submission of a request until the first response is produced1Classification of Scheduling ActivityClassification of Scheduling ActivityLong-term: which process to admit?Medium-term: which process to swap in or out?Short-term: which ready process to execute next?1Queuing Diagram for SchedulingQueuing Diagram for Scheduling1Long-Term SchedulingLong-Term SchedulingDetermines which programs are admitted to the system for processingControls the degree of multiprogrammingAttempts to keep a balanced mix of processor-bound and I/O-bound processesCPU usageSystem performance1Medium-Term SchedulingMedium-Term SchedulingMakes swapping decisions based on the current degree of multiprogrammingControls which remains resident in memory and which jobs must be swapped out to reduce degree of multiprogramming1Short-Term SchedulingShort-Term SchedulingSelects from among ready processes in memory which one is to execute nextThe selected process is allocated the CPUIt is invoked on events that may lead to choose another process for execution:Clock interruptsI/O interruptsOperating system calls and trapsSignals1Characterization of Scheduling PoliciesCharacterization of Scheduling PoliciesThe selection function determines which ready process is selected next for executionThe decision mode specifies the instants in time the selection function is exercisedNonpreemptiveOnce a process is in the running state, it will continue until it terminates or blocks for an I/OPreemptiveCurrently running process may be interrupted and moved to the Ready state by the OSPrevents one process from monopolizing the processor1Short-Term SchedulerShort-Term SchedulerDispatcherDispatcherThe dispatcher is the module that gives control of the CPU to the process selected by the short-term schedulerThe functions of the dispatcher include:Switching contextSwitching to user modeJumping to the location in the user program to restart executionThe dispatch latency must be minimal1The CPU-I/O CycleThe CPU-I/O CycleProcesses require alternate use of processor and I/O in a repetitive fashionEach cycle consist of a CPU burst followed by an I/O burst A process terminates on a CPU burstCPU-bound processes have longer CPU bursts than I/O-bound processes1Short-Tem Scheduling CriteriaShort-Tem Scheduling CriteriaUser-oriented criteriaResponse Time: Elapsed time between the submission of a request and the receipt of a responseTurnaround Time: Elapsed time between the submission of a process to its completionSystem-oriented criteriaProcessor utilizationThroughput: number of process completed per unit timefairness1Scheduling AlgorithmsScheduling AlgorithmsFirst-Come, First-Served SchedulingShortest-Job-First SchedulingAlso referred to asShortest Process NextPriority SchedulingRound-Robin SchedulingMultilevel Queue SchedulingMultilevel Feedback Queue Scheduling1Process Mix ExampleProcess Mix ExampleProcessArrivalTimeServiceTime123450246836452Service time = total processor time needed in one (CPU-I/O) cycleJobs with long service time are CPU-bound jobs and are referredto as “long jobs”1First Come First Served (FCFS)First Come First Served (FCFS)Selection function: the process that has been waiting the longest in the ready queue (hence, FCFS)Decision mode: non-preemptivea process runs until it blocks for an I/O1FCFS drawbacksFCFS drawbacksFavors CPU-bound processesA CPU-bound process monopolizes the processorI/O-bound processes have to wait until completion of CPU-bound process I/O-bound processes may have to wait even after their I/Os are completed (poor device utilization)Better I/O device utilization could be achieved if I/O bound processes had higher priority1Shortest Job First (Shortest Job First (Shortest Process NextShortest Process Next))Selection function: the process with the shortest expected CPU burst timeI/O-bound processes will be selected firstDecision mode: non-preemptiveThe required processing time, i.e., the CPU burst time, must be estimated for each process1SJF / SPN CritiqueSJF / SPN CritiquePossibility of starvation for longer processes Lack of preemption is not suitable in a time sharing environmentSJF/SPN implicitly incorporates prioritiesShortest jobs are given preferencesCPU bound process have lower priority, but a process doing no I/O could still monopolize the CPU if it is the first to enter the system1Is SJF/SPN optimal?Is SJF/SPN optimal?If the metric is turnaround time (response time), is SJF or FCFS better?For FCFS, resp_time=(3+9+13+18+20)/5 = ?Note that Rfcfs = 3+(3+6)+(3+6+4)+…. = ?For SJF, resp_time=(3+9+11+15+20)/5 = ?Note that Rfcfs = 3+(3+6)+(3+6+4)+…. = ?Which one is smaller? Is this always the case?1Is SJF/SPN optimal?Is SJF/SPN optimal?Take each scheduling discipline, they both choose the same subset of jobs (first k jobs).At some point, each discipline chooses a different job (FCFS chooses k1 SJF chooses k2)Rfcfs=nR1+(n-1)R2+…+(n-k1)Rk1+….+(n-k2) Rk2+….+RnRsjf=nR1+(n-1)R2+…+(n-k2)Rk2+….+(n-k1) Rk1+….+RnWhich one is smaller? Rfcfs or Rsjf?1PrioritiesPrioritiesImplemented by having multiple ready queues to represent each level of priorityScheduler the process of a higher priority over one of lower priorityLower-priority may suffer starvationTo alleviate starvation allow dynamic prioritiesThe priority of a process changes based on its age or execution history1Selection function: same as FCFSDecision mode: preemptivea process is allowed to run until the time slice period (quantum, typically from 10 to 100 ms) has expireda clock interrupt occurs and the running process is put on the ready queue Round-RobinRound-Robin1RR Time QuantumRR Time QuantumQuantum must be substantially larger than the time required to handle the clock interrupt


View Full Document

Pitt CS 1550 - CPU scheduling

Download CPU scheduling
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view CPU scheduling and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view CPU scheduling 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?