Lecture Topics: 11/15 CPU scheduling: –Scheduling goals and algorithms.

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

OS, , Part II CPU Scheduling Department of Computer Engineering, PSUWannarat Suntiamorntut.
CPU Scheduling Questions answered in this lecture: What is scheduling vs. allocation? What is preemptive vs. non-preemptive scheduling? What are FCFS,
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
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.
Scheduling Algorithms
Day 25 Uniprocessor scheduling. Algorithm: Selection function Selection function – which process among ready processes to select. w – time spent in system,
Chapter 3: CPU Scheduling
Operating Systems 1 K. Salah Module 2.1: CPU Scheduling Scheduling Types Scheduling Criteria Scheduling Algorithms Performance Evaluation.
CS 311 – Lecture 23 Outline Kernel – Process subsystem Process scheduling Scheduling algorithms User mode and kernel mode Lecture 231CS Operating.
Scheduling in Batch Systems
What we will cover…  CPU Scheduling  Basic Concepts  Scheduling Criteria  Scheduling Algorithms  Evaluations 1-1 Lecture 4.
Job scheduling Queue discipline.
02/11/2004CSCI 315 Operating Systems Design1 CPU Scheduling Algorithms Notice: The slides for this lecture have been largely based on those accompanying.
1 Scheduling Algorithms FCFS First-Come, First-Served Round-robin SJF Multilevel Feedback Queues.
1Chapter 05, Fall 2008 CPU Scheduling The CPU scheduler (sometimes called the dispatcher or short-term scheduler): Selects a process from the ready queue.
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.
Chapter 6 CPU SCHEDULING.
1 Scheduling Processes. 2 Processes Each process has state, that includes its text and data, procedure call stack, etc. This state resides in memory.
Lecture Topics: 11/13 Semaphores Deadlock Scheduling.
Operating Systems Lecture Notes CPU Scheduling Matthew Dailey Some material © Silberschatz, Galvin, and Gagne, 2002.
Scheduling. Alternating Sequence of CPU And I/O Bursts.
1 CSE451 Scheduling Autumn 2002 Gary Kimura Lecture #6 October 11, 2002.
CPU Scheduling CSCI 444/544 Operating Systems Fall 2008.
1 Our focus  scheduling a single CPU among all the processes in the system  Key Criteria: Maximize CPU utilization Maximize throughput Minimize waiting.
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, Lecture 7: CPU Scheduling Chapter 5.
Lecture 7: Scheduling preemptive/non-preemptive scheduler CPU bursts
Operating Systems 1 K. Salah Module 2.2: CPU Scheduling Scheduling Types Scheduling Criteria Scheduling Algorithms Performance Evaluation.
Processor Scheduling Hank Levy. 22/4/2016 Goals for Multiprogramming In a multiprogramming system, we try to increase utilization and thruput by overlapping.
1 CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling.
CPU Scheduling Operating Systems CS 550. Last Time Deadlock Detection and Recovery Methods to handle deadlock – Ignore it! – Detect and Recover – Avoidance.
Introduction to Operating System Created by : Zahid Javed CPU Scheduling Fifth Lecture.
Operating Systems Scheduling. Scheduling Short term scheduler (CPU Scheduler) –Whenever the CPU becomes idle, a process must be selected for execution.
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 CS Introduction to Operating Systems.
Process Scheduling. Scheduling Strategies Scheduling strategies can broadly fall into two categories  Co-operative scheduling is where the currently.
CPU scheduling.  Single Process  one process at a time  Maximum CPU utilization obtained with multiprogramming  CPU idle :waiting time is wasted 2.
1 Lecture 5: CPU Scheduling Operating System Fall 2006.
Lecture 5 Scheduling. Today CPSC Tyson Kendon Updates Assignment 1 Assignment 2 Concept Review Scheduling Processes Concepts Algorithms.
Lecturer 5: Process Scheduling Process Scheduling  Criteria & Objectives Types of Scheduling  Long term  Medium term  Short term CPU Scheduling Algorithms.
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.
CPU Scheduling Andy Wang Operating Systems COP 4610 / CGS 5765.
CPU SCHEDULING.
April 6, 2001 Gary Kimura Lecture #6 April 6, 2001
CPU scheduling 6. Schedulers, CPU Scheduling 6.1. Schedulers
Scheduling (Priority Based)
CPU Scheduling.
CPU Scheduling Basic Concepts Scheduling Criteria
CPU Scheduling G.Anuradha
Chapter 6: CPU Scheduling
Chapter 5: CPU Scheduling
Andy Wang Operating Systems COP 4610 / CGS 5765
Operating System Concepts
TDC 311 Process Scheduling.
CSE 451: Operating Systems Winter 2003 Lecture 6 Scheduling
Processor Scheduling Hank Levy 1.
Chapter 6: Scheduling Algorithms Dr. Amjad Ali
CPU Scheduling: Basic Concepts
CSE 451: Operating Systems Winter 2001 Lecture 6 Scheduling
Presentation transcript:

Lecture Topics: 11/15 CPU scheduling: –Scheduling goals and algorithms

Review: Process State A process can be in one of several states (new, ready, running, waiting, terminated). The OS keeps track of process state by maintaining a queue of PCBs for each state. The ready queue contains PCBs of processes that are waiting to be assigned to the CPU.

The Scheduling Problem Need to share the CPU between multiple processes in the ready queue. – OS needs to decide which process gets the CPU next. – Once a process is selected, OS needs to do some work to get the process running on the CPU.

How Scheduling Works The scheduler is responsible for choosing a process from the ready queue. The scheduling algorithm implemented by this module determines how process selection is done. The scheduler hands the selected process off to the dispatcher which gives the process control of the CPU.

When Does The OS Make Scheduling Decisions ? Scheduling decisions are always made: –when a process is terminated, and –when a process switches from running to waiting. Scheduling decisions are made when an interrupt occurs only in a preemptive system.

How is the CPU Shared? Non-preemptive scheduling: –The scheduler must wait for a running process to voluntarily relinquish the CPU (process either terminates or blocks). –Why would you choose this approach? –What are the disadvantages of using this scheme?

How is the CPU Shared? Preemptive scheduling: –The OS can force a running process to give up control of the CPU, allowing the scheduler to pick another process. –What are the advantages of using this scheme? –What are the implementation challenges presented by this approach?

Scheduling Goals Maximize throughput and resource utilization. –Need to overlap CPU and I/O activities. Minimize response time, waiting time and turnaround time. Share CPU in a fair way. May be difficult to meet all these goals-- sometimes need to make tradeoffs.

CPU and I/O Bursts Typical process execution pattern: use the CPU for a while (CPU burst), then do some I/O operations (IO burst). CPU bound processes perform I/O operations infrequently and tend to have long CPU bursts. I/O bound processes spend less time doing computation and tend to have short CPU bursts.

Scheduling Algorithms First Come First Served (FCFS) –Scheduler selects the process at the head of the ready queue; typically non- preemptive –Example: 3 processes arrive at the ready queue in the following order: P1 ( CPU burst = 24 ms) P2 ( CPU burst = 3 ms) P3 ( CPU burst = 3 ms)

Scheduling Algorithms First Come First Served (FCFS) –Example: What’s the average waiting time? FCFS pros & cons: +Simple to implement. –Average waiting time can be large if processes with short CPU bursts get stuck behind processes with long CPU bursts.

Scheduling Algorithms Round Robin (RR) –FCFS + preemptive scheduling. –Ready queue is treated as a circular queue. –Each process gets the CPU for a time quantum (or time slice), typically ms. –A process runs until it blocks, terminates, or uses up its time slice.

Scheduling Algorithms Round Robin (RR) –Example: Assuming a time quantum of 4 ms, what’s the average waiting time? Issue: What’s the right value for the time quantum? Too long => poor response time Too short => poor throughput

Scheduling Algorithms Round Robin (RR) RR pros & cons: +Works well for short jobs; typically used in timesharing systems. –High overhead due to frequent context switches. –Increases average waiting time, especially if CPU bursts are the same length and need more than one time quantum.

Scheduling Algorithms Priority Scheduling –Select the process with the highest priority. –Priority based on some attribute of the process (e.g., memory requirements, owner of process, etc.) Issue: –Starvation: low priority jobs may wait indefinitely. Can prevent starvation by aging (increase process priority as a function of the waiting time).

Scheduling Algorithms Shortest Job First (SJF) –Special case of priority scheduling (priority = expected length of CPU burst) –Non-preemptive version: scheduler chooses the process with the least amount of work to do (shortest CPU burst). –Preemptive version: scheduler chooses the process with the shortest remaining time to completion -- a running process can be interrupted.

Scheduling Algorithms Shortest Job First (SJF) –Example: What’s the average waiting time? Issue: How do you predict the future? –In practice systems use past process behavior to predict the length of the next CPU burst.

Scheduling Algorithms Shortest Job First (SJF) SJF pros & cons: +Better average response time. +It’s the best you can do to minimize average response time-- can prove the algorithm is optimal. –Difficult to predict the future. –Unfair-- possible starvation (many short jobs can keep long jobs from making any progress).

Scheduling Algorithms Multi-level Queues –Maintain multiple ready queues based on process “type” (e.g., interactive queue, CPU bound queue, etc.). –Each queue has a priority; a process is permanently assigned to a queue. –May use a different scheduling algorithm in each queue. –Need to decide how to schedule between queues.

Scheduling Algorithms Multi-level Feedback Queues –Adaptive algorithm: Processes can move between queues based on past behavior. –Round robin scheduling in each queue -- time slice increases in lower priority levels. –Queue assignment: Put new process in highest priority queue. If CPU burst takes longer than one time quantum, drop one level. If CPU burst completes before timer expires, move up one level.