DOC PREVIEW
UMD CMSC 412 - Operating Systems

This preview shows page 1-2-24-25 out of 25 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 25 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 25 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 25 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 25 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 25 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

15.1Silberschatz, Galvin and Gagne ©2005Operating System ConceptsCSMC 412CSMC 412Operating SystemsProf. Ashok K Agrawala© 2005 Ashok AgrawalaSet 55.2Silberschatz, Galvin and Gagne ©2005Operating System ConceptsCPU SchedulingCPU Scheduling Basic Concepts Scheduling Criteria  Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling Thread Scheduling Operating Systems Examples Java Thread Scheduling Algorithm Evaluation25.3Silberschatz, Galvin and Gagne ©2005Operating System ConceptsBasic ConceptsBasic Concepts Maximum CPU utilization obtained with multiprogramming CPU–I/O Burst Cycle – Process execution consists of a cycle of CPU execution and I/O wait CPU burst distribution5.4Silberschatz, Galvin and Gagne ©2005Operating System ConceptsAlternating Sequence of CPU And I/O BurstsAlternating Sequence of CPU And I/O Bursts35.5Silberschatz, Galvin and Gagne ©2005Operating System ConceptsHistogram of CPUHistogram of CPU--burst Timesburst Times5.6Silberschatz, Galvin and Gagne ©2005Operating System ConceptsCPU SchedulerCPU Scheduler Selects from among the processes in memory that are ready to execute, and allocates the CPU to one of them CPU scheduling decisions may take place when a process:1. Switches from running to waiting state2. Switches from running to ready state3. Switches from waiting to ready4. Terminates Scheduling under 1 and 4 is nonpreemptive All other scheduling is preemptive45.7Silberschatz, Galvin and Gagne ©2005Operating System ConceptsDispatcherDispatcher Dispatcher module gives control of the CPU to the process selected by the short-term scheduler; this involves:z switching contextz switching to user modez jumping to the proper location in the user program to restart that program Dispatch latency – time it takes for the dispatcher to stop one process and start another running5.8Silberschatz, Galvin and Gagne ©2005Operating System ConceptsScheduling CriteriaScheduling Criteria CPU utilization – keep the CPU as busy as possible Throughput – # of processes that complete their execution per time unit Turnaround time – amount of time to execute a particular process Waiting time – amount of time a process has been waiting in the ready queue Response time – amount of time it takes from when a request was submitted until the first response is produced, not output (for time-sharing environment)55.9Silberschatz, Galvin and Gagne ©2005Operating System ConceptsOptimization CriteriaOptimization Criteria Max CPU utilization Max throughput Min turnaround time  Min waiting time  Min response time5.10Silberschatz, Galvin and Gagne ©2005Operating System ConceptsFirstFirst--Come, FirstCome, First--Served (FCFS) SchedulingServed (FCFS) SchedulingProcess Burst TimeP124P23P33 Suppose that the processes arrive in the order: P1, P2, P3 The Gantt Chart for the schedule is: Waiting time for P1= 0; P2= 24; P3 = 27 Average waiting time: (0 + 24 + 27)/3 = 17P1P2P324 27 30065.11Silberschatz, Galvin and Gagne ©2005Operating System ConceptsFCFS Scheduling (Cont.)FCFS Scheduling (Cont.)Suppose that the processes arrive in the orderP2, P3, P1 The Gantt chart for the schedule is: Waiting time for P1 = 6;P2= 0; P3 = 3 Average waiting time: (6 + 0 + 3)/3 = 3 Much better than previous case Convoy effect short process behind long processP1P3P2633005.12Silberschatz, Galvin and Gagne ©2005Operating System ConceptsShortestShortest--JobJob--First (SJR) SchedulingFirst (SJR) Scheduling Associate with each process the length of its next CPU burst. Use these lengths to schedule the process with the shortest time Two schemes: z nonpreemptive – once CPU given to the process it cannot be preempted until completes its CPU burstz preemptive – if a new process arrives with CPU burst length less than remaining time of current executing process, preempt. This scheme is know as the Shortest-Remaining-Time-First (SRTF) SJF is optimal – gives minimum average waiting time for a given set of processes75.13Silberschatz, Galvin and Gagne ©2005Operating System ConceptsProcess Arrival Time Burst TimeP10.0 7P22.0 4P34.0 1P45.0 4 SJF (non-preemptive) Average waiting time = (0 + 6 + 3 + 7)/4 - 4Example of NonExample of Non--Preemptive SJFPreemptive SJFP1P3P273160P48 125.14Silberschatz, Galvin and Gagne ©2005Operating System ConceptsExample of Preemptive SJFExample of Preemptive SJFProcess Arrival Time Burst TimeP10.0 7P22.0 4P34.0 1P45.0 4 SJF (preemptive) Average waiting time = (9 + 1 + 0 +2)/4 - 3P1P3P242110P45 7P2P11685.15Silberschatz, Galvin and Gagne ©2005Operating System ConceptsDetermining Length of Next CPU BurstDetermining Length of Next CPU Burst Can only estimate the length Can be done by using the length of previous CPU bursts, using exponential averaging:Define 4.10 , 3.burst CPU next the for value predicted 2.burst CPU of lenght actual 1.1≤≤==+αατnthnnt().1 1 nnntταατ−+==5.16Silberschatz, Galvin and Gagne ©2005Operating System ConceptsPrediction of the Length of the Next CPU BurstPrediction of the Length of the Next CPU Burst95.17Silberschatz, Galvin and Gagne ©2005Operating System ConceptsExamples of Exponential AveragingExamples of Exponential Averaging α =0z τn+1= τnz Recent history does not count α =1z τn+1= tnz Only the actual last CPU burst counts If we expand the formula, we get:τn+1= α tn+(1 - α) α tn-1 + …+(1 - α )j α tn-1 + …+(1 - α )n=1 tnτ0 Since both α and (1 - α) are less than or equal to 1, each successive term has less weight than its predecessor5.18Silberschatz, Galvin and Gagne ©2005Operating System ConceptsPriority SchedulingPriority Scheduling A priority number (integer) is associated with each process The CPU is allocated to the process with the highest priority (smallest integer ≡ highest priority)z Preemptivez nonpreemptive SJF is a priority scheduling where priority is the predicted next CPU burst time Problem ≡ Starvation – low priority processes may never execute Solution ≡ Aging – as time progresses increase the priority of the process105.19Silberschatz, Galvin and Gagne ©2005Operating System ConceptsRound Robin (RR)Round Robin (RR) Each process gets a small unit of CPU time (time quantum), usually 10-100 milliseconds. After this time has elapsed, the process is preempted and added to the end of the ready queue. If


View Full Document

UMD CMSC 412 - Operating Systems

Documents in this Course
Security

Security

65 pages

Deadlocks

Deadlocks

22 pages

Set 2

Set 2

70 pages

Project 2

Project 2

21 pages

Load more
Download Operating Systems
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 Operating Systems 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 Operating Systems 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?