Project 2 – solution code

Slides:



Advertisements
Similar presentations
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 17 Scheduling III.
Advertisements

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.
Ceng Operating Systems Chapter 2.2 : Process Scheduling Process concept  Process scheduling Interprocess communication Deadlocks Threads.
Chapter 3: CPU Scheduling
Operating Systems 1 K. Salah Module 2.1: CPU Scheduling Scheduling Types Scheduling Criteria Scheduling Algorithms Performance Evaluation.
Scheduling in Batch Systems
CS 3013 & CS 502 Summer 2006 Scheduling1 The art and science of allocating the CPU and other resources to processes.
Cs238 CPU Scheduling Dr. Alan R. Davis. CPU Scheduling The objective of multiprogramming is to have some process running at all times, to maximize CPU.
CS 104 Introduction to Computer Science and Graphics Problems Operating Systems (2) Process Management 10/03/2008 Yang Song (Prepared by Yang Song and.
Wk 2 – Scheduling 1 CS502 Spring 2006 Scheduling The art and science of allocating the CPU and other resources to processes.
Job scheduling Queue discipline.
7/12/2015Page 1 Process Scheduling B.Ramamurthy. 7/12/2015Page 2 Introduction An important aspect of multiprogramming is scheduling. The resources that.
1 Lecture 10: Uniprocessor Scheduling. 2 CPU Scheduling n The problem: scheduling the usage of a single processor among all the existing processes in.
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Emery Berger University of Massachusetts, Amherst Operating Systems CMPSCI 377 Lecture.
1 Scheduling Algorithms FCFS First-Come, First-Served Round-robin SJF Multilevel Feedback Queues.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
CPU Scheduling Chapter 6 Chapter 6.
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.
More Scheduling cs550 Operating Systems David Monismith.
MM Process Management Karrie Karahalios Spring 2007 (based off slides created by Brian Bailey)
Fair Resource Access & Allocation  OS 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.
Chapter 6 Scheduling. Basic concepts Goal is maximum utilization –what does this mean? –cpu pegged at 100% ?? Most programs are I/O bound Thus some other.
Scheduling. Alternating Sequence of CPU And I/O Bursts.
Real-Time Scheduling CS4730 Fall 2010 Dr. José M. Garrido Department of Computer Science and Information Systems Kennesaw State University.
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.
CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Thread Scheduling Multiple-Processor Scheduling Operating Systems Examples Algorithm.
CS Spring 2011 CS 414 – Multimedia Systems Design Lecture 31 – Multimedia OS (Part 1) Klara Nahrstedt Spring 2011.
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.
RTOS task scheduling models
ITFN 2601 Introduction to Operating Systems Lecture 4 Scheduling.
1 Real-Time Scheduling. 2Today Operating System task scheduling –Traditional (non-real-time) scheduling –Real-time scheduling.
Uniprocessor Scheduling Chapter 9. Aim of Scheduling Assign processes to be executed by the processor or processors: –Response time –Throughput –Processor.
Processor Scheduling Hank Levy. 22/4/2016 Goals for Multiprogramming In a multiprogramming system, we try to increase utilization and thruput by overlapping.
Lecture Topics: 11/15 CPU scheduling: –Scheduling goals and algorithms.
CS333 Intro to Operating Systems Jonathan Walpole.
1 CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling.
CS Spring 2010 CS 414 – Multimedia Systems Design Lecture 32 – Multimedia OS Klara Nahrstedt Spring 2010.
CPU Scheduling Operating Systems CS 550. Last Time Deadlock Detection and Recovery Methods to handle deadlock – Ignore it! – Detect and Recover – Avoidance.
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.
Chapter 9 Uniprocessor Scheduling Operating Systems: Internals and Design Principles, 6/E William Stallings Dave Bremer Otago Polytechnic, N.Z. ©2008,
Process Scheduling. Scheduling Strategies Scheduling strategies can broadly fall into two categories  Co-operative scheduling is where the currently.
Basic Concepts Maximum CPU utilization obtained with multiprogramming
Lecturer 5: Process Scheduling Process Scheduling  Criteria & Objectives Types of Scheduling  Long term  Medium term  Short term CPU Scheduling Algorithms.
Scheduling.
CPU Scheduling Andy Wang Operating Systems COP 4610 / CGS 5765.
CPU Scheduling Scheduling processes (or kernel-level threads) onto the cpu is one of the most important OS functions. The cpu is an expensive resource.
CPU SCHEDULING.
Chapter 5a: CPU Scheduling
Chapter 2 Scheduling.
Chapter 8 – Processor Scheduling
Uniprocessor Scheduling
Chapter 2.2 : Process Scheduling
Process Scheduling B.Ramamurthy 11/18/2018.
Chapter 6: CPU Scheduling
Andy Wang Operating Systems COP 4610 / CGS 5765
Process Scheduling Decide which process should run and for how long
Process Scheduling B.Ramamurthy 2/23/2019.
Process Scheduling B.Ramamurthy 4/11/2019.
Process Scheduling B.Ramamurthy 4/7/2019.
Uniprocessor Scheduling
Presentation transcript:

Project 2 – solution code Project 2 solution code in files for project 3: Mutex solution in Synch.c But this code has several flaws! If you copied this, we will know! Producer/Consumer and Dining Philosophers solution in Proj2Sol.pdf Make sure you study and understand the solutions! Try to identify errors in your own project 2 code Email your thoughts on these to me and the TA over the next two days for extra credit Important: if the solutions you handed in were copied let me know by email a.s.a.p.

Project 3 Part 1: The Sleeping Barber problem Use semaphores and mutex variables for thread synchronization You decide how to test your code!! We’re not providing the sample output for this one! Part 2: The Gaming Parlor problem Use monitors and condition variables for synchronization Avoid deadlock when handling resource requests Sample output given in handout

CS 333 Introduction to Operating Systems Class 8 - Scheduling Jonathan Walpole Computer Science Portland State University

Process state model New Process Termination Ready Running Blocked

CPU scheduling criteria CPU Utilization – how busy is the CPU? Throughput – how many jobs finished/unit time? Turnaround Time – how long from job submission to job termination? Response Time – how long (on average) does it take to get a “response” from a “stimulus”? Missed deadlines – were any deadlines missed?

Scheduler options Priorities May use priorities to determine who runs next Dynamic vs. Static algorithms Dynamically alter the priority of the tasks while they are in the system (possibly with feedback) Static algorithms typically assign a fixed priority when the job is initially started. Preemptive vs. Nonpreemptive Preemptive systems allow the task to be interrupted at any time so that the O.S. can take over again.

Scheduling policies First-Come, First Served (FIFO) Shortest Job First (non-preemptive) Shortest Job First (with preemption) Round-Robin Scheduling Priority Scheduling Real-Time Scheduling

First-Come, First-Served (FIFO) Start jobs in the order they arrive (FIFO queue) Run each job until completion

First-Come, First-Served (FIFO) Start jobs in the order they arrive (FIFO queue) Run each job until completion Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

First-Come, First-Served (FIFO) Total time taken, from submission to completion Start jobs in the order they arrive (FIFO queue) Run each job until completion Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

First-Come, First-Served (FIFO) Total time taken, from submission to completion Start jobs in the order they arrive (FIFO queue) Run each job until completion Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 Arrival Times of the Jobs 5 10 15 20

First-Come, First-Served (FIFO) Total time taken, from submission to completion Start jobs in the order they arrive (FIFO queue) Run each job until completion Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 5 10 15 20

First-Come, First-Served (FIFO) Total time taken, from submission to completion Start jobs in the order they arrive (FIFO queue) Run each job until completion Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 5 10 15 20

First-Come, First-Served (FIFO) Total time taken, from submission to completion Start jobs in the order they arrive (FIFO queue) Run each job until completion Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 5 10 15 20

First-Come, First-Served (FIFO) Total time taken, from submission to completion Start jobs in the order they arrive (FIFO queue) Run each job until completion Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 5 10 15 20

First-Come, First-Served (FIFO) Total time taken, from submission to completion Start jobs in the order they arrive (FIFO queue) Run each job until completion Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 5 10 15 20

First-Come, First-Served (FIFO) Total time taken, from submission to completion Start jobs in the order they arrive (FIFO queue) Run each job until completion Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 5 10 15 20

First-Come, First-Served (FIFO) Total time taken, from submission to completion Start jobs in the order they arrive (FIFO queue) Run each job until completion Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 5 10 15 20

First-Come, First-Served (FIFO) Total time taken, from submission to completion Start jobs in the order they arrive (FIFO queue) Run each job until completion Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 5 10 15 20

First-Come, First-Served (FIFO) Total time taken, from submission to completion Start jobs in the order they arrive (FIFO queue) Run each job until completion Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 5 10 15 20

First-Come, First-Served (FIFO) Total time taken, from submission to completion Start jobs in the order they arrive (FIFO queue) Run each job until completion Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 5 10 15 20

First-Come, First-Served (FIFO) Total time taken, from submission to completion Start jobs in the order they arrive (FIFO queue) Run each job until completion Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 5 10 15 20

First-Come, First-Served (FIFO) Total time taken, from submission to completion Start jobs in the order they arrive (FIFO queue) Run each job until completion Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 5 10 15 20

First-Come, First-Served (FIFO) Total time taken, from submission to completion Start jobs in the order they arrive (FIFO queue) Run each job until completion Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 0 2 2 6 1 3 4 4 5 4 6 5 7 5 8 2 10 5 10 15 20

First-Come, First-Served (FIFO) Total time taken, from submission to completion Start jobs in the order they arrive (FIFO queue) Run each job until completion Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 0 3 2 2 6 1 7 3 4 4 5 9 4 6 5 7 12 5 8 2 10 12 5 10 15 20

Shortest Job First Select the job with the shortest (expected) running time Non-Preemptive

Shortest Job First Select the job with the shortest (expected) running time Non-Preemptive Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 Same Job Mix 5 10 15 20

Shortest Job First Select the job with the shortest (expected) running time Non-Preemptive Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 5 10 15 20

Shortest Job First Select the job with the shortest (expected) running time Non-Preemptive Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 5 10 15 20

Shortest Job First Select the job with the shortest (expected) running time Non-Preemptive Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 5 10 15 20

Shortest Job First Select the job with the shortest (expected) running time Non-Preemptive Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 5 10 15 20

Shortest Job First Select the job with the shortest (expected) running time Non-Preemptive Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 5 10 15 20

Shortest Job First Select the job with the shortest (expected) running time Non-Preemptive Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 5 10 15 20

Shortest Job First Select the job with the shortest (expected) running time Non-Preemptive Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 5 10 15 20

Shortest Job First Select the job with the shortest (expected) running time Non-Preemptive Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 5 10 15 20

Shortest Job First Select the job with the shortest (expected) running time Non-Preemptive Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 5 10 15 20

Shortest Job First Select the job with the shortest (expected) running time Non-Preemptive Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 5 10 15 20

Shortest Job First Select the job with the shortest (expected) running time Non-Preemptive Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 5 10 15 20

Shortest Job First Select the job with the shortest (expected) running time Non-Preemptive Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 5 10 15 20

Shortest Job First Select the job with the shortest (expected) running time Non-Preemptive Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 0 2 2 6 1 3 4 4 7 4 6 5 9 5 8 2 1 5 10 15 20

Shortest Job First Select the job with the shortest (expected) running time Non-Preemptive Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 0 3 2 2 6 1 7 3 4 4 7 11 4 6 5 9 14 5 8 2 1 3 5 10 15 20

Shortest Remaining Time Preemptive version of SJF Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 Same Job Mix 5 10 15 20

Shortest Remaining Time Preemptive version of SJF Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 5 10 15 20

Shortest Remaining Time Preemptive version of SJF Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 5 10 15 20

Shortest Remaining Time Preemptive version of SJF Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 5 10 15 20

Shortest Remaining Time Preemptive version of SJF Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 5 10 15 20

Shortest Remaining Time Preemptive version of SJF Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 5 10 15 20

Shortest Remaining Time Preemptive version of SJF Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 5 10 15 20

Shortest Remaining Time Preemptive version of SJF Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 5 10 15 20

Shortest Remaining Time Preemptive version of SJF Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 5 10 15 20

Shortest Remaining Time Preemptive version of SJF Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 5 10 15 20

Shortest Remaining Time Preemptive version of SJF Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 5 10 15 20

Shortest Remaining Time Preemptive version of SJF Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 5 10 15 20

Shortest Remaining Time Preemptive version of SJF Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 5 10 15 20

Shortest Remaining Time Preemptive version of SJF Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 5 10 15 20

Shortest Remaining Time Preemptive version of SJF Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 0 2 2 6 7 3 4 4 0 4 6 5 9 5 8 2 0 5 10 15 20

Shortest Remaining Time Preemptive version of SJF Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 0 3 2 2 6 7 13 3 4 4 0 4 4 6 5 9 14 5 8 2 0 2 5 10 15 20

Round-Robin Scheduling Goal: Enable interactivity Limit the amount of CPU that a process can have at one time. Time quantum Amount of time the OS gives a process before intervention The “time slice” Typically: 1 to 100ms

Round-Robin Scheduling Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 5 10 15 20

Round-Robin Scheduling Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 Ready List: 5 10 15 20

Round-Robin Scheduling Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 Ready List: 5 10 15 20

Round-Robin Scheduling Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 Ready List: 5 10 15 20

Round-Robin Scheduling Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 Ready List: 5 10 15 20

Round-Robin Scheduling Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 Ready List: 5 10 15 20

Round-Robin Scheduling Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 Ready List: 5 10 15 20

Round-Robin Scheduling Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 Ready List: 5 10 15 20

Round-Robin Scheduling Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 Ready List: 5 10 15 20

Round-Robin Scheduling Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 Ready List: 5 10 15 20

Round-Robin Scheduling Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 Ready List: 5 10 15 20

Round-Robin Scheduling Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 Ready List: 5 10 15 20

Round-Robin Scheduling Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 Ready List: 5 10 15 20

Round-Robin Scheduling Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 Ready List: 5 10 15 20

Round-Robin Scheduling Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 Ready List: 5 10 15 20

Round-Robin Scheduling Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 Ready List: 5 10 15 20

Round-Robin Scheduling Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 Ready List: 5 10 15 20

Round-Robin Scheduling Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 Ready List: 5 10 15 20

Round-Robin Scheduling Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 Ready List: 5 10 15 20

Round-Robin Scheduling Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 Ready List: 5 10 15 20

Round-Robin Scheduling Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 Ready List: 5 10 15 20

Round-Robin Scheduling Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 Ready List: 5 10 15 20

Round-Robin Scheduling Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 Ready List: 5 10 15 20

Round-Robin Scheduling Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 Ready List: 5 10 15 20

Round-Robin Scheduling Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 Ready List: 5 10 15 20

Round-Robin Scheduling Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 Ready List: 5 10 15 20

Round-Robin Scheduling Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 5 10 15 20

Round-Robin Scheduling Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 1 4 2 2 6 10 16 3 4 4 9 13 4 6 5 9 14 5 8 2 5 7 5 10 15 20

Round-Robin Scheduling Effectiveness of round-robin depends on The number of jobs, and The size of the time quantum. Large # of jobs means that the time between scheduling of a single job increases Slow responses Larger time quantum means that the time between the scheduling of a single job also increases Smaller time quantum means higher processing rates but also more overhead!

Scheduling in general purpose systems

Priority scheduling Assign a priority (number) to each process Schedule processes based on their priority Higher priority processes get more CPU time Managing priorities Can use “nice” to reduce your priority Can periodically adjust a process’ priority Prevents starvation of a lower priority process Can improve performance of I/O-bound processes by basing priority on fraction of last quantum used

Multi-Level Queue Scheduling Multiple queues, each with its own priority. Equivalently: each priority level has its own ready queue Within each queue...Round-robin scheduling. Simplist Approach: A Process’s priority is fixed & unchanging High priority CPU Low priority

Multi-Level Feedback Queue Scheduling Problem: Fixed priorities are too restrictive Processes exhibit varying ratios of CPU to I/O times. Dynamic Priorities Priorities are altered over time, as process behavior changes!

Multi-Level Feedback Queue Scheduling Problem: Fixed priorities are too restrictive Processes exhibit varying ratios of CPU to I/O times. Dynamic Priorities Priorities are altered over time, as process behavior changes! Issue: When do you change the priority of a process and how often?

Multi-Level Feedback Queue Scheduling Problem: Fixed priorities are too restrictive Processes exhibit varying ratios of CPU to I/O times. Dynamic Priorities Priorities are altered over time, as process behavior changes! Issue: When do you change the priority of a process and how often? Solution: Let the amount of CPU used be an indication of how a process is to be handled Expired time quantum  more processing needed Unexpired time quantum  less processing needed Adjusting quantum and frequency vs. adjusting priority?

Multi-Level Feedback Queue Scheduling n priority levels, round-robin scheduling within a level Quanta increase as priority decreases Jobs are demoted to lower priorities if they do not complete within the current quantum ?? High priority CPU Low priority

Multi-Level Feedback Queue Scheduling Details, details, details... Starting priority? Frequency of moving between priorities? How long should the time quantum be?

Lottery Scheduling Scheduler gives each thread some lottery tickets To select the next process to run... The scheduler randomly selects a lottery number The winning process gets to run Example Thread A gets 50 tickets Thread B gets 15 tickets Thread C gets 35 tickets There are 100 tickets outstanding.

Lottery Scheduling Scheduler gives each thread some lottery tickets. To select the next process to run... The scheduler randomly selects a lottery number The winning process gets to run Example Thread A gets 50 tickets 50% of CPU Thread B gets 15 tickets 15% of CPU Thread C gets 35 tickets 35% of CPU There are 100 tickets outstanding.

Lottery Scheduling Scheduler gives each thread some lottery tickets. To select the next process to run... The scheduler randomly selects a lottery number The winning process gets to run Example Thread A gets 50 tickets 50% of CPU Thread B gets 15 tickets 15% of CPU Thread C gets 35 tickets 35% of CPU There are 100 tickets outstanding. • Flexible • Fair • Responsive

A Brief Look at Real-Time Systems Assume processes are relatively periodic Fixed amount of work per period (e.g. sensor systems or multimedia data)

A Brief Look at Real-Time Systems Assume processes are relatively periodic Fixed amount of work per period (e.g. sensor systems or multimedia data) Two “main” types of schedulers... Rate-Monotonic Schedulers Earliest-Deadline-First Schedulers

A Brief Look at Real-Time Systems Assume processes are relatively periodic Fixed amount of work per period (e.g. sensor systems or multimedia data) Two “main” types of schedulers... Rate-Monotonic Schedulers Assign a fixed, unchanging priority to each process No dynamic adjustment of priorities Less aggressive allocation of processor Earliest-Deadline-First Schedulers Assign dynamic priorities based upon deadlines

A Brief Look at Real-Time Systems Typically real-time systems involve several steps (that aren’t in traditional systems) Admission control All processes must ask for resources ahead of time. If sufficient resources exist, the job is “admitted” into the system. Resource allocation Upon admission... the appropriate resources need to be reserved for the task. Resource enforcement Carry out the resource allocations properly

Rate Monotonic Schedulers For preemptable, periodic processes (tasks) Assigns a fixed priority to each task T = The period of the task C = The amount of processing per task period In RMS scheduling, the question to answer is... What priority should be assigned to a given task? Process P1 T = 1 second C = 1/2 second / period

Rate Monotonic Schedulers P1 P2

Rate Monotonic Schedulers P1 P2 P1PRI > P2PRI P2PRI > P1PRI

Rate Monotonic Schedulers P1 P2 P1PRI > P2PRI P2PRI > P1PRI Which is best?

Rate Monotonic Schedulers Assign shortest period tasks to the highest priorities Admission control is difficult... < 69% There is a standard formula > 69% It may be possible, but need to do more complex analysis

Rate Monotonic Schedulers Assumptions: Processes complete (yield) within their period Independent processes Same CPU requirements per burst Other non-periodic processes have no deadlines Instantaneous preemption with no overhead

Earliest Deadline First When processes do not have periodic execution or constant CPU requirements... When processes have deadline specifications... Unlike RMS, EDF uses dynamic priorities (based upon earliest deadline first) (+) 100% processor utilization …? (-) Need to keep track of deadlines Admission Control Just check to see if 100% processor utilization. Sum the Ci/Ti’s and see if less than or equal to 1 What about overhead?

Quiz What are the main tasks of the scheduler? What is the difference between preemptive and non-preemptive scheduling? What is the advantage of a shorter scheduling quantum? What is the advantage of a longer scheduling quantum? Why is feedback scheduling useful for interactive jobs? Are these scheduling policies subject to starvation? Shortest Job First scheduling? Round Robin scheduling? First Come First Served scheduling? Priority scheduling? Earliest Deadline First scheduling?