DOC PREVIEW
UMD CMSC 412 - Operating Systems

This preview shows page 1-2-3-4-5-6-45-46-47-48-49-50-51-92-93-94-95-96-97 out of 97 pages.

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

Unformatted text preview:

1CSMC 412Operating SystemsProf. Ashok K Agrawala© 2006 Ashok AgrawalaSet 5September 2006 1CMSC 412 Set 52CPU Scheduling• Basic Concepts• Scheduling Criteria • Scheduling Algorithms• Multiple-Processor Scheduling• Real-Time Scheduling• Thread Scheduling• Operating Systems Examples• Java Thread Scheduling• Algorithm EvaluationSeptember 2006 CMSC 412 Set 53Basic 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 distributionSeptember 2006 CMSC 412 Set 54Alternating Sequence of CPU And I/O BurstsSeptember 2006 CMSC 412 Set 55Histogram of CPU-burst TimesSeptember 2006 CMSC 412 Set 56CPU 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 preemptiveSeptember 2006 CMSC 412 Set 57Dispatcher• Dispatcher module gives control of the CPU to the process selected by the short-term scheduler; this involves:– switching context– switching to user mode– 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 runningSeptember 2006 CMSC 412 Set 58Scheduling 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)September 2006 CMSC 412 Set 59Optimization Criteria• Max CPU utilization• Max throughput• Min turnaround time • Min waiting time • Min response timeSeptember 2006 CMSC 412 Set 510First-Come, First-Served (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 300September 2006 CMSC 412 Set 511FCFS 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 processP1P3P263 300September 2006 CMSC 412 Set 512Shortest-Job-First (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: – nonpreemptive – once CPU given to the process it cannot be preempted until completes its CPU burst– 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 processesSeptember 2006 CMSC 412 Set 513Process 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 Non-Preemptive SJFP1P3P273 160P48 12September 2006 CMSC 412 Set 514Example 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 7P2P116September 2006 CMSC 412 Set 515Determining 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September 2006 CMSC 412 Set 516Prediction of the Length of the Next CPU BurstSeptember 2006 CMSC 412 Set 517Examples of Exponential Averaging•  =0– n+1= n– Recent history does not count•  =1– n+1= tn– 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 predecessorSeptember 2006 CMSC 412 Set 518Priority 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)– Preemptive– 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 processSeptember 2006 CMSC 412 Set 519Round 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 there are n processes in the ready queue and the time quantum is q, then each process gets 1/n of the CPU time in chunks of at most q time units at once. No process waits more than (n-1)q time units.• Performance– q large  FIFO– q small  q must be large with respect to context switch, otherwise overhead is too highSeptember 2006 CMSC 412 Set 520Example of RR with Time Quantum = 20Process Burst TimeP153P217P368P424• The Gantt chart is: • Typically, higher average turnaround than SJF, but better responseP1P2P3P4P1P3P4P1P3P30 20 37 57 77 97 117 121 134 154 162September 2006 CMSC 412 Set 521Time Quantum and Context Switch TimeSeptember 2006 CMSC 412 Set 522Turnaround Time Varies With The Time QuantumSeptember 2006 CMSC 412 Set 523Multilevel Queue• Ready queue is partitioned into separate queues:foreground (interactive)background (batch)• Each queue has its own scheduling algorithm– foreground – RR– background – FCFS• Scheduling must be done between the queues– Fixed priority scheduling; (i.e., serve all from foreground then from background). Possibility of


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?