Operating Systems CPU Scheduling. Agenda for Today What is Scheduler and its types Short-term scheduler Dispatcher Reasons for invoking scheduler Optimization.

Slides:



Advertisements
Similar presentations
CPU Scheduling.
Advertisements

Chapter 5: CPU Scheduling
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 2 nd Edition Chapter 6a: CPU Scheduling.
 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
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.
CPU Scheduling CS 3100 CPU Scheduling1. Objectives To introduce CPU scheduling, which is the basis for multiprogrammed operating systems To describe various.
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
02/11/2004CSCI 315 Operating Systems Design1 CPU Scheduling Algorithms Notice: The slides for this lecture have been largely based on those accompanying.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
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.
Chapter 6: CPU Scheduling
CS212: OPERATING SYSTEM Lecture 3: Process Scheduling 1.
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.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
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.
6.1 CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling Algorithm Evaluation.
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.
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.
CPU SCHEDULING.
Scheduling (Priority Based)
Chapter 6: CPU Scheduling
CPU Scheduling G.Anuradha
Chapter 6: CPU Scheduling
Module 5: CPU Scheduling
Operating System Concepts
3: CPU Scheduling Basic Concepts Scheduling Criteria
Chapter5: CPU Scheduling
Chapter 6: CPU Scheduling
Chapter 5: CPU Scheduling
Chapter 6: CPU Scheduling
Module 5: CPU Scheduling
Chapter 6: CPU Scheduling
CPU Scheduling.
CPU Scheduling: Basic Concepts
Module 5: CPU Scheduling
Presentation transcript:

Operating Systems CPU Scheduling

Agenda for Today What is Scheduler and its types Short-term scheduler Dispatcher Reasons for invoking scheduler Optimization criteria FCFS, SJF, SRTF, RR, Multi level Queues With Examples

CPU Scheduling  Scheduling processes in the ready queue  Short-term scheduler  Different types of schedulers

Life of a Process

Histogram of CPU- burst Times

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

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

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

CPU Scheduler  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

CPU Scheduler  Scheduling under 1 and 4 is nonpreemptive.  All other scheduling is preemptive.

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

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)

Optimization Criteria  Maximize CPU utilization  Maximize throughput  Minimize turnaround time  Minimize waiting time  Minimize response time

FCFS Scheduling  The process that enters the ready queue first is scheduled first, regardless of the size of its next CPU burst  Example: ProcessBurst Time P 1 24 P 2 3 P 3 3  Suppose that processes arrive into the system in the order: P 1, P 2, P 3

FCFS Scheduling  Processes are served in the order: P 1, P 2, P 3  The Gantt Chart for the schedule is:  Waiting times P 1 = 0; P 2 = 24; P 3 = 27  Average waiting time: ( )/3 = 17 P1P1 P2P2 P3P

 Suppose that processes arrive in the order: P 2, P 3, P 1.  The Gantt chart for the schedule is:  Waiting time for P 1 = 6; P 2 = 0 ; P 3 = 3  Average waiting time: ( )/3 = 3  Convoy effect short process behind long process P1P1 P3P3 P2P FCFS Scheduling

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.

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.

Non-Preemptive SJF  Process Arrival Time Burst Time P P P P  Gantt chart  Average waiting time = ( )/4 = 4 P1P1 P3P3 P2P P4P4 12

Preemptive SJF  Process Arrival TimeBurst Time P P P P  Gantt chart  Average waiting time = ( )/4 = 3 P3P3 P2P P4P4 57 P2P2 P1P1 16 P1P1

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

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.

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

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

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

Round Robin Example ProcessBurst Time P 1 53 — 33 — 13 P 2 17 P 3 68 — 48 — 28 — 8 P 4 24 — 4  The Gantt chart with quantum 20 is: P1P1 P2P2 P3P3 P4P4 P1P1 P3P3 P4P4 P1P1 P3P3 P3P

Round Robin Example ProcessTurnaround TimeWaiting Time P – 53 = 81 P – 17 = 20 P – 68 = 94 P – 24 = 97  Average waiting time = 73  Average waiting time for SJF = 38  Typically, higher average turnaround than SJF, but better response.

Quantum vs Context Switch Process Time = 10 Quantum Context Switches

Multilevel Queues  Ready queue is partitioned into separate queues: - foreground (interactive) - background (batch)  Each queue has its own priority and scheduling algorithm: - foreground – RR - background – FCFS

Multilevel Queues  Scheduling must be done across queues.  Fixed priority scheduling; i.e., serve all from foreground then from background.  Time slice – each queue gets a certain percentage of CPU time, e.g., 80% to foreground in RR and 20% to background in FCFS

Multilevel Queues

Multilevel Feedback Queues  A process can move between the various queues; aging can be implemented this way.  Multilevel-feedback-queue scheduler defined by the following parameters:  Number of queues  Scheduling algorithms for each queue

Multilevel Feedback Queues  Method used to determine when to upgrade a process  Method used to determine when to demote a process  Method used to determine which queue a process will enter when that process needs service

Multilevel Feedback Queues