Scheduling (Priority Based)

Slides:



Advertisements
Similar presentations
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 2 nd Edition Chapter 6a: CPU Scheduling.
Advertisements

 Basic Concepts  Scheduling Criteria  Scheduling Algorithms.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 5: CPU Scheduling.
Operating Systems Chapter 6
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
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.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
Chapter 5-CPU Scheduling
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.
CS212: OPERATING SYSTEM Lecture 3: Process Scheduling 1.
Chapter 6 CPU SCHEDULING.
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.
Chapter 5 CPU Scheduling Bernard Chen Spring 2007.
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.
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.
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.
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.
lecture 5: CPU Scheduling
CPU SCHEDULING.
Chapter 6: CPU Scheduling
Dan C. Marinescu Office: HEC 439 B. Office hours: M, Wd 3 – 4:30 PM.
Chapter 5a: CPU Scheduling
Operating Systems Processes Scheduling.
Process Scheduling B.Ramamurthy 9/16/2018.
CPU Scheduling.
Chapter 6: CPU Scheduling
Chapter 6: CPU Scheduling
Chapter 6: CPU Scheduling
CPU Scheduling Basic Concepts Scheduling Criteria
CPU Scheduling G.Anuradha
Chapter 6: CPU Scheduling
Module 5: CPU Scheduling
Chapter 5: CPU Scheduling
Operating Systems Lecture 15.
Operating System Concepts
3: CPU Scheduling Basic Concepts Scheduling Criteria
Chapter5: CPU Scheduling
Chapter 5: CPU Scheduling
Chapter 6: CPU Scheduling
Chapter 5: CPU Scheduling
Chapter 6: CPU Scheduling
Chapter 5: CPU Scheduling
Lecture 2 Part 3 CPU Scheduling
Operating System , Fall 2000 EA101 W 9:00-10:00 F 9:00-11:00
Process Scheduling B.Ramamurthy 4/19/2019.
Chapter 6: CPU Scheduling
Module 5: CPU Scheduling
Process Scheduling B.Ramamurthy 5/7/2019.
CPU SCHEDULING CPU SCHEDULING.
Chapter 6: Scheduling Algorithms Dr. Amjad Ali
CPU Scheduling: Basic Concepts
Chapter 6: CPU Scheduling
CPU Scheduling.
CPU Scheduling: Basic Concepts
Module 5: CPU Scheduling
Chapter 5: CPU Scheduling
Presentation transcript:

Scheduling (Priority Based) Lecture 09

CPU Scheduling Scheduling processes in the ready queue Short-term scheduler Different types of schedulers 16 September 2018

Life of a Process 16 September 2018

Histogram of CPU-burst Times 16 September 2018

CPU Scheduler Short-term scheduler Selects a process from among the processes in the ready queue Invokes the dispatcher to have the CPU allocated to the selected process 16 September 2018

Dispatcher Dispatcher 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 start (or restart) it 16 September 2018

Dispatcher Dispatch latency – time it takes for the dispatcher to stop one process and start another running. Typically, a few microseconds 16 September 2018

CPU Scheduler CPU scheduling decisions may take place when a process: Switches from running to waiting state Switches from running to ready state Switches from waiting to ready Terminates 16 September 2018

CPU Scheduler Scheduling under 1 and 4 is nonpreemptive. All other scheduling is preemptive. 16 September 2018

Scheduling 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 16 September 2018

Scheduling Criteria 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) 16 September 2018

Optimization Criteria Maximize CPU utilization Maximize throughput Minimize turnaround time Minimize waiting time Minimize response time 16 September 2018

FCFS Scheduling The process that enters the ready queue first is scheduled first, regardless of the size of its next CPU burst Example: Process Burst Time P1 24 P2 3 P3 3 Suppose that processes arrive into the system in the order: P1, P2 , P3 16 September 2018

FCFS Scheduling Processes are served in the order: P1, P2, P3 The Gantt Chart for the schedule is: Waiting times P1 = 0; P2 = 24; P3 = 27 Average waiting time: (0+24+27)/3 = 17 P1 P2 P3 24 27 30 16 September 2018

FCFS Scheduling Suppose that processes arrive in the order: P2 , 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 Convoy effect short process behind long process P1 P3 P2 6 3 30 16 September 2018

Shortest-Job-First (SJF) Scheduling Process with the shortest CPU burst is scheduled first. Non-preemptive – once CPU given to a process it cannot be preempted until completes its CPU burst. 16 September 2018

Shortest-Job-First (SJF) Scheduling Preemptive – if a new process arrives with CPU burst length less than remaining time of current executing process, preempt it—Shortest-Remaining-Time-First (SRTF). SJF is optimal non-preemptive scheduling algorithm – gives minimum average waiting time for a given set of processes. 16 September 2018

Non-Preemptive SJF Process Arrival Time Burst Time P1 0.0 7 P2 2.0 4 Gantt chart Average waiting time = (0+6+3+7)/4 = 4 P1 P3 P2 7 16 P4 12 16 September 2018

Preemptive SJF Process Arrival Time Burst Time P1 0.0 7 P2 2.0 4 Gantt chart Average waiting time = (9 + 1 + 0 +2)/4 = 3 P3 P2 4 2 11 P4 5 7 P1 16 16 September 2018

Example of Shortest-remaining-time-first Now we add the concepts of varying arrival times and preemption to the analysis ProcessA arri Arrival TimeT Burst Time P1 0 8 P2 1 4 P3 2 9 P4 3 5 Preemptive SJF Gantt Chart Average waiting time = [(10-1)+(1-1)+(17-2)+5-3)]/4 = 26/4 = 6.5 msec 16 September 2018

SJF—CPU Burst of a Process Can only estimate the length of the next CPU burst. Can be done by using the length of previous CPU bursts, using exponential averaging. 16 September 2018

SJF is Optimal Logical Argument: Decrease in the wait times for short processes is much more than increase in the wait times for long processes P1 P2 P3 5 3 2 P3 P2 P1 2 3 5 16 September 2018

Priority 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 Non-preemptive 16 September 2018

Priority Scheduling 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. 16 September 2018

Example of Priority Scheduling Process A arrive Burst Time Priority P1 10 3 P2 1 1 P3 2 4 P4 1 5 P5 5 2 Priority scheduling Gantt Chart Average waiting time = 8.2 msec 16 September 2018

Round Robin (RR) Each process gets a small unit of CPU time, called time slice or quantum, which is usually 10-100 milliseconds. After this time has elapsed, the process is preempted and added to the end of the ready queue. 16 September 2018

Round Robin (RR) If there are n processes in the ready queue, the time quantum is q, and context switch time is tcs, then no process waits more than (n-1)(q+tcs) time units Used in time-sharing systems where response time is an important performance criteria 16 September 2018

Round Robin (RR) Performance q large  FCFS q small  q must be large with respect to context switch, otherwise overhead is too high. 16 September 2018

Round Robin Example The Gantt chart with quantum 20 is: Process Burst Time P1 53 — 33 — 13 P2 17 P3 68 — 48 — 28 — 8 P4 24 — 4 The Gantt chart with quantum 20 is: P1 P2 P3 P4 20 37 57 77 97 117 121 134 154 162 16 September 2018

Round Robin Example Average waiting time = 73 Process Turnaround Time Waiting Time P1 134 134 – 53 = 81 P2 37 37 – 17 = 20 P3 162 162 – 68 = 94 P4 121 121 – 24 = 97 Average waiting time = 73 Average waiting time for SJF = 38 Typically, higher average turnaround than SJF, but better response. 16 September 2018

Example of RR with Time Quantum = 4 Process Burst Time P1 24 P2 3 P3 3 The Gantt chart is: Typically, higher average turnaround than SJF, but better response q should be large compared to context switch time q usually 10ms to 100ms, context switch < 10 usec 16 September 2018

Quantum vs Context Switch Process Time = 10 Quantum Context Switches 12 0 6 1 1 9 16 September 2018

Turnaround Time vs Quantum 16 September 2018