DOC PREVIEW
UMD CMSC 412 - Operating Systems

This preview shows page 1-2-3-4-5-6 out of 17 pages.

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

Unformatted text preview:

17.1Operating System ConceptsCSMC 412Operating SystemsProf. Ashok K Agrawala© 2004 Ashok AgrawalaSet 7(chapter 6)7.2Operating System ConceptsCPU Scheduling Basic Concepts Scheduling Criteria  Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling Algorithm Evaluation27.3Operating System 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 distribution7.4Operating System ConceptsAlternating Sequence of CPU And I/O Bursts37.5Operating System ConceptsHistogram of CPU-burst Times7.6Operating System ConceptsCPU 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 state.2. Switches from running to ready state.3. Switches from waiting to ready.4. Terminates.Scheduling under 1 and 4 is nonpreemptive. All other scheduling is preemptive.47.7Operating System ConceptsDispatcher 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 running.7.8Operating System ConceptsScheduling 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)57.9Operating System ConceptsOptimization Criteria Max CPU utilization Max throughput Min turnaround time  Min waiting time  Min response time7.10Operating System ConceptsFirst-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 30067.11Operating System ConceptsFCFS 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 processP1P3P2633007.12Operating System ConceptsShortest-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 processes.77.13Operating 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 Non-Preemptive SJFP1P3P273160P48 127.14Operating System ConceptsExample 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 7P2P11687.15Operating System ConceptsDetermining 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.≤≤==+αατ1nthnnt().tnnnταατ−+==11 7.16Operating System ConceptsPrediction of the Length of the Next CPU Burst97.17Operating System ConceptsExamples 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 predecessor.7.18Operating System ConceptsPriority 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 process.107.19Operating System ConceptsRound 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 high.7.20Operating System ConceptsExample of RR with Time Quantum = 20Process Burst TimeP153P217P368P424 The Gantt chart is:  Typically, higher average turnaround than SJF, but better response.P1P2P3P4P1P3P4P1P3P30 20 37 57 77 97 117 121 134 154 162117.21Operating System ConceptsTime Quantum and Context Switch Time7.22Operating System ConceptsTurnaround Time Varies With The Time Quantum127.23Operating System ConceptsMultilevel Queue Ready queue is partitioned into separate queues:foreground (interactive)background (batch) Each queue has its own scheduling algorithm, foreground – RRbackground – FCFS Scheduling must be done between the queues.) Fixed priority scheduling; (i.e., serve all from foreground then from background). Possibility of starvation.) Time slice – each queue gets a certain amount of CPU time which it can schedule amongst its processes; i.e., 80% to


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?