COT 4600 Operating Systems Spring 2011 Dan C. Marinescu Office: HEC 304 Office hours: Tu-Th 5:00-6:00 PM.

Slides:



Advertisements
Similar presentations
Scheduling Criteria CPU utilization – keep the CPU as busy as possible (from 0% to 100%) Throughput – # of processes that complete their execution per.
Advertisements

Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 2 nd Edition Chapter 6a: CPU Scheduling.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 5: CPU Scheduling.
Operating Systems Chapter 6
Chap 5 Process Scheduling. Basic Concepts Maximum CPU utilization obtained with multiprogramming CPU–I/O Burst Cycle – Process execution consists of a.
Chapter 5 CPU Scheduling. CPU Scheduling Topics: Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling.
Operating Systems CPU Scheduling. Agenda for Today What is Scheduler and its types Short-term scheduler Dispatcher Reasons for invoking scheduler Optimization.
CPU Scheduling Algorithms
Chapter 3: CPU Scheduling
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 5: CPU Scheduling.
CS 311 – Lecture 23 Outline Kernel – Process subsystem Process scheduling Scheduling algorithms User mode and kernel mode Lecture 231CS Operating.
02/06/2008CSCI 315 Operating Systems Design1 CPU Scheduling Algorithms Notice: The slides for this lecture have been largely based on those accompanying.
Scheduling in Batch Systems
Chapter 6: CPU Scheduling. 5.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 2, 2005 Chapter 6: CPU Scheduling Basic.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
What we will cover…  CPU Scheduling  Basic Concepts  Scheduling Criteria  Scheduling Algorithms  Evaluations 1-1 Lecture 4.
Chapter 5-CPU Scheduling
7/12/2015Page 1 Process Scheduling B.Ramamurthy. 7/12/2015Page 2 Introduction An important aspect of multiprogramming is scheduling. The resources that.
02/11/2004CSCI 315 Operating Systems Design1 CPU Scheduling Algorithms Notice: The slides for this lecture have been largely based on those accompanying.
Chapter 5: CPU Scheduling. 5.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 2, 2005 Basic Concepts Maximum CPU utilization.
CPU-Scheduling Whenever the CPU becomes idle, the operating system must select one of the processes in the ready queue to be executed. The short term scheduler.
Chapter 6: CPU Scheduling
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-3 CPU Scheduling Department of Computer Science and Software Engineering.
CS212: OPERATING SYSTEM Lecture 3: Process Scheduling 1.
Chapter 6 CPU SCHEDULING.
COT 4600 Operating Systems Fall 2009 Dan C. Marinescu Office: HEC 439 B Office hours: Tu-Th 3:00-4:00 PM.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
Scheduling. Alternating Sequence of CPU And I/O Bursts.
Silberschatz and Galvin  Operating System Concepts Module 5: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor.
Alternating Sequence of CPU And I/O Bursts. Histogram of CPU-burst Times.
CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Thread Scheduling Multiple-Processor Scheduling Operating Systems Examples Algorithm.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 5: CPU Scheduling.
Chapter 5 CPU Scheduling Bernard Chen Spring 2007.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Lecture 7: CPU Scheduling Chapter 5.
Chapter 5: CPU Scheduling. 5.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 5: CPU Scheduling Basic Concepts Scheduling Criteria.
Chapter 5: Process Scheduling. 5.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Basic Concepts Maximum CPU utilization can be obtained.
1 11/29/2015 Chapter 6: CPU Scheduling l Basic Concepts l Scheduling Criteria l Scheduling Algorithms l Multiple-Processor Scheduling l Real-Time Scheduling.
Chapter 5: CPU Scheduling. 5.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 2, 2005 Chapter 5: CPU Scheduling Basic.
Silberschatz and Galvin  Operating System Concepts Module 5: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor.
1 CS.217 Operating System By Ajarn..Sutapart Sappajak,METC,MSIT Chapter 5 CPU Scheduling Slide 1 Chapter 5 CPU Scheduling.
1 CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling.
Introduction to Operating System Created by : Zahid Javed CPU Scheduling Fifth Lecture.
1 Uniprocessor Scheduling Chapter 3. 2 Alternating Sequence of CPU And I/O Bursts.
Chapter 4 CPU Scheduling. 2 Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling Algorithm Evaluation.
Lecture 4 CPU scheduling. Basic Concepts Single Process  one process at a time Maximum CPU utilization obtained with multiprogramming CPU idle :waiting.
CPU Scheduling G.Anuradha Reference : Galvin. CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time.
CPU scheduling.  Single Process  one process at a time  Maximum CPU utilization obtained with multiprogramming  CPU idle :waiting time is wasted 2.
1 Module 5: Scheduling CPU Scheduling Scheduling Algorithms Reading: Chapter
Basic Concepts Maximum CPU utilization obtained with multiprogramming
1 Lecture 5: CPU Scheduling Operating System Fall 2006.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 6: CPU Scheduling.
CPU Scheduling Algorithms CSSE 332 Operating Systems Rose-Hulman Institute of Technology.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 5: CPU Scheduling.
Chapter 5: CPU Scheduling. 5.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 5: CPU Scheduling Basic Concepts Scheduling Criteria.
1 Chapter 5: CPU Scheduling. 2 Basic Concepts Scheduling Criteria Scheduling Algorithms.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
Dan C. Marinescu Office: HEC 439 B. Office hours: M, Wd 3 – 4:30 PM.
Scheduling (Priority Based)
CPU Scheduling.
Chapter 6: CPU Scheduling
Operating System Concepts
COT 4600 Operating Systems Spring 2011
COT 4600 Operating Systems Fall 2009
CGS 3763 Operating Systems Concepts Spring 2013
Chapter 5: CPU Scheduling
CGS 3763 Operating Systems Concepts Spring 2013
CGS 3763 Operating Systems Concepts Spring 2013
CPU Scheduling.
Chapter 5: CPU Scheduling
Presentation transcript:

COT 4600 Operating Systems Spring 2011 Dan C. Marinescu Office: HEC 304 Office hours: Tu-Th 5:00-6:00 PM

Lecture 20 - Tuesday April 5, 2011 Last time:  Tread coordination with a bounded buffer Today:  Scheduling  Multi-level memories  Memory characterization  Multilevel memories management using virtual memory  Adding multi-level memory management to virtual memory Next Time:  Page replacement algorithms Lecture 202

Scheduling Basic concepts; scheduling objectives. Scheduling policies  First-Come First-Serve (FCFS)  Shortest Job First (SJF)  Round Robin (RR)  Preemptive/non-preemptive scheduling  Priority scheduling Priority inversion Schedulers  CPU burst. Estimation of the CPU burst  Multi-level queues  Multi-level queues with feedback  Example: the UNIX scheduler Lecture 203

Scheduling – basic concepts Scheduling  assigning jobs to machines. A schedule S  a plan on how to process N jobs using one or machines. Scheduling in the general case in a NP complete problem. A job 1 <= j <- N is characterized by  C i S  completion time of job j under schedule S  p i  processing time  r i  release time; the time when the job is available for processing  d i  due time ; the time when the job should be completed. u i =0 if C i S <= d i and u i =1 otherwise  L j = C i S - d i  lateness A schedule S is characterized by  The makespan C max = max C i S  Average completion time Lecture 204

Scheduling objectives Performance metrics:  CPU Utilization  Fraction of time CPU does useful work over total time  Throughput  Number of jobs finished per unit of time  Turnaround time  Time spent by a job in the system  Response time  Time to get the results  Waiting time  Time waiting to start processing All these are random variables  we are interested in averages!! The objectives - system managers (M) and users (U):  Maximize CPU utilization  M  Maximize throughput  M  Minimize turnaround time  U  Minimize waiting time  U  Minimize response time  U 5Lecture 20

Scheduling policies Burst time  time required by a thread to use the processor/core Time slice/quantum  time a thread is allowed to use the processor/core Preemptive scheduling  A thread could be forced to release the control of the processor Policies  First-Come First-Serve  FCFS  Shortest Job First  SJF  Round Robin  RR 6Lecture 20

First-Come First-Served (FCFS) ThreadBurst Time P 1 24 P 2 3 P 3 3 Processes arrive in the order: P 1  P 2  P 3 Gantt Chart for the schedule: Waiting time for P 1 = 0; P 2 = 24; P 3 = 27 Average waiting time: ( )/3 = 17 Convoy effect  short process behind long process P1P1 P2P2 P3P Lecture 20

The effect of the release time on FCFS scheduling Now threads arrive in the order: P 2  P 3  P 1 Gantt chart: Waiting time for P 1 = 6; P 2 = 0 ; P 3 = 3 Average waiting time: ( )/3 = 3 Much better!! P1P1 P3P3 P2P Lecture 20

Shortest-Job-First (SJF) Use the length of the next burst to schedule the thread/process with the shortest time. SJF is optimal  minimum average waiting time for a given set of threads/processes Two schemes:  Non-preemptive  the thread/process cannot be preempted until completes its burst  Preemptive  if a new thread/process arrives with burst length less than remaining time of current executing process, preempt. known as Shortest-Remaining-Time-First (SRTF) 9Lecture 20

Example of non-preemptive SJF ThreadRelease timeBurst Time P P P P SJF (non-preemptive) Average waiting time = ( )/4 = 4 P1P1 P3P3 P2P P4P Lecture 20

Example of Shortest-Remaining-Time-First (SRTF) (Preemptive SJF) ThreadRelease timeBurst time P P P P Shortest-Remaining-Time-First Average waiting time = ( )/4 = 3 P1P1 P3P3 P2P P4P4 57 P2P2 P1P Lecture 20

Round Robin (RR) Each process gets a small unit of CPU time (time quantum), usually milliseconds. After this time has elapsed, the thread/process is preempted and added to the end of the ready queue. If there are n threads/processes in the ready queue and the time quantum is q, then each thread/process gets 1/n of the processor time in chunks of at most q time units at once. No thread/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 12Lecture 20

RR with time slice q = 20 ThreadBurst Time P 1 53 P 2 17 P 3 68 P 4 24 Typically, higher average turnaround than SJF, but better response P1P1 P2P2 P3P3 P4P4 P1P1 P3P3 P4P4 P1P1 P3P3 P3P Lecture 20

Time slice (quantum) and context switch time 14Lecture 20

Turnaround time function of time quantum 15Lecture 20

JobRelease time WorkStart timeFinish timeWait time till start Time in system A B = 83 – 1 = 28 – 1 = 7 C = 108 – 3 = 510 – 3 = 7 A B = – 1 = 9 C = 505 – 3 = 2 A – 0 = 6 B – 1 = 010 – 1 = 9 C32585 – 3 = 28 – 3 = 5 16Lecture 20

Scheduling policy Average waiting time till the job started Average time in system FCFS7/317/3 SJF4/314/3 RR3/320/3 17Lecture 20

Priority scheduling Each thread/process has a priority and the one with the highest priority (smallest integer  highest priority) is scheduled next.  Preemptive  Non-preemptive SJF is a priority scheduling where priority is the predicted next CPU burst time Problem  Starvation – low priority threads/processes may never execute Solution to starvation  Aging – as time progresses increase the priority of the thread/process Priority my be computed dynamically 18Lecture 20

Priority inversion A lower priority thread/process prevents a higher priority one from running. T 3 has the highest priority, T 1 has the lowest priority; T 1 and T 3 share a lock. T 1 acquires the lock, then it is suspended when T 3 starts. Eventually T 3 requests the lock and it is suspended waiting for T 1 to release the lock. T 2 has higher priority than T 1 and runs; neither T 3 nor T 1 can run; T 1 due to its low priority, T 3 because it needs the lock help by T 1. Allow a low priority thread holding a lock to run with the higher priority of the thread which requests the lock 19Lecture 20