Comp 204: Computer Systems and Their Implementation. Lecture 10: Process Scheduling

Similar documents
Chapter 6: CPU Scheduling. Basic Concepts. Histogram of CPU-burst Times. CPU Scheduler. Dispatcher. Alternating Sequence of CPU And I/O Bursts

Roadmap. Tevfik Ko!ar. CSC Operating Systems Spring Lecture - V CPU Scheduling - I. Louisiana State University.

Roadmap. Tevfik Koşar. CSE 421/521 - Operating Systems Fall Lecture - V CPU Scheduling - I. University at Buffalo.

CPU Scheduling. Basic Concepts Scheduling Criteria Scheduling Algorithms. Unix Scheduler

CS 153 Design of Operating Systems Winter 2016

Principles of Operating Systems

Motivation. Types of Scheduling

Operating System 9 UNIPROCESSOR SCHEDULING

Project 2 solution code

Lecture 11: CPU Scheduling

Intro to O/S Scheduling. Intro to O/S Scheduling (continued)

Scheduling I. Today. Next Time. ! Introduction to scheduling! Classical algorithms. ! Advanced topics on scheduling

CPU Scheduling. Disclaimer: some slides are adopted from book authors and Dr. Kulkarni s slides with permission

Journal of Global Research in Computer Science

Operating Systems Process Scheduling Prof. Dr. Armin Lehmann

Uniprocessor Scheduling

Review of Round Robin (RR) CPU Scheduling Algorithm on Varying Time Quantum

CPU Scheduling. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

A Paper on Modified Round Robin Algorithm

CPU Scheduling. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

CPU Scheduling. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

Process Scheduling Course Notes in Operating Systems 1 (OPESYS1) Justin David Pineda

A COMPARATIVE ANALYSIS OF SCHEDULING ALGORITHMS

ENGG4420 CHAPTER 4 LECTURE 3 GENERALIZED TASK SCHEDULER

Advanced Types Of Scheduling

Pallab Banerjee, Probal Banerjee, Shweta Sonali Dhal

GENERALIZED TASK SCHEDULER

LEAST-MEAN DIFFERENCE ROUND ROBIN (LMDRR) CPU SCHEDULING ALGORITHM

Process Scheduling for John Russo generated Mon Nov 07 13:57:15 EST 2011

CS162 Operating Systems and Systems Programming Lecture 10. Tips for Handling Group Projects Thread Scheduling

Mixed Round Robin Scheduling for Real Time Systems

Recall: FCFS Scheduling (Cont.) Example continued: Suppose that processes arrive in order: P 2, P 3, P 1 Now, the Gantt chart for the schedule is:

SELF OPTIMIZING KERNEL WITH HYBRID SCHEDULING ALGORITHM

Analysis of Adaptive Round Robin Algorithm and Proposed Round Robin Remaining Time Algorithm

Efficient Round Robin Scheduling Algorithm with Dynamic Time Slice

Scheduling II. To do. q Proportional-share scheduling q Multilevel-feedback queue q Multiprocessor scheduling q Next Time: Memory management

SCHEDULING AND CONTROLLING PRODUCTION ACTIVITIES

Scheduling: Introduction

Real-Time and Embedded Systems (M) Lecture 4

Queue based Job Scheduling algorithm for Cloud computing

Lecture Note #4: Task Scheduling (1) EECS 571 Principles of Real-Time Embedded Systems. Kang G. Shin EECS Department University of Michigan

Comparative Study of Parallel Scheduling Algorithm for Parallel Job

CHAPTER 4 CONTENT October :10 PM

Motivating Examples of the Power of Analytical Modeling

Clock-Driven Scheduling

Smarter Round Robin Scheduling Algorithm for Cloud Computing and Big Data

A Survey of Resource Scheduling Algorithms in Green Computing

Job Scheduling in Cluster Computing: A Student Project

Lecture 6: Scheduling. Michael O Boyle Embedded Software

IJRASET: All Rights are Reserved

System. Figure 1: An Abstract System. If we observed such an abstract system we might measure the following quantities:

OPERATING SYSTEMS. Systems and Models. CS 3502 Spring Chapter 03

Node Allocation In Grid Computing Using Optimal Resouce Constraint (ORC) Scheduling

3. Scheduling issues. Common approaches /2. Common approaches /1. Common approaches / /17 UniPD / T. Vardanega 06/03/2017

General Terms Measurement, Performance, Design, Theory. Keywords Dynamic load balancing, Load sharing, Pareto distribution, 1.

Application the Queuing Theory in the Warehouse Optimization Jaroslav Masek, Juraj Camaj, Eva Nedeliakova

Gang Scheduling Performance on a Cluster of Non-Dedicated Workstations

DEADLINE MONOTONIC ALGORITHM (DMA)

SINGLE MACHINE SEQUENCING. ISE480 Sequencing and Scheduling Fall semestre

Priority-Driven Scheduling of Periodic Tasks. Why Focus on Uniprocessor Scheduling?

On the Comparison of CPLEX-Computed Job Schedules with the Self-Tuning dynp Job Scheduler

CS 471 Operating Systems. Yue Cheng. George Mason University Fall 2017

Limited-preemptive Earliest Deadline First Scheduling of Real-time Tasks on Multiprocessors

Hamdy A. Taha, OPERATIONS RESEARCH, AN INTRODUCTION, 5 th edition, Maxwell Macmillan International, 1992

Dynamic Fractional Resource Scheduling for HPC Workloads

LOADING AND SEQUENCING JOBS WITH A FASTEST MACHINE AMONG OTHERS

Real-Time Scheduling Theory and Ada

Hierarchical Job Scheduling for Clusters of Workstations

A COMPARATIVE ANALYSIS OF SCHEDULING POLICIES IN A DISTRIBUTED SYSTEM USING SIMULATION

Production Job Scheduling for Parallel Shared Memory Systems

Real-Time Systems. Modeling Real-Time Systems

QUANTITATIVE EVALUATION OF JOB AND RESOURCES FOR BETTER SELECTION TO IMPROVE MAKESPAN IN GRID SCHEDULING

BUSSINES SIMULATING PROCES FOR THE PRODUCTION SURROUND, USING QUEUEING SYSTEM SIMULATION WITH WINQSB

EFFECT OF CROSS OVER OPERATOR IN GENETIC ALGORITHMS ON ANTICIPATORY SCHEDULING

Job Scheduling based on Size to Hadoop

Evaluation of Task Assignment Policies for Supercomputing Servers: The Case for Load Unbalancing and Fairness

Resource Allocation Strategies in a 2-level Hierarchical Grid System

Job Batching and Scheduling for Parallel Non- Identical Machines via MILP and Petri Nets

The BEST Desktop Soft Real-Time Scheduler

Optimising Inbound, Warehousing and Outbound Strategies

Comparative Analysis of Scheduling Algorithms of Cloudsim in Cloud Computing

TMS TRAFFIC MANAGEMENT SYSTEM GREATER CONVENIENCE AT YOUR SERVICE ZONES

Introduction to Real-Time Systems. Note: Slides are adopted from Lui Sha and Marco Caccamo

Optimized Virtual Resource Deployment using CloudSim

Factors Influencing Job Rejections in Cloud Environment

Analysis of the job shop system with transport and setup times in deadlock-free operating conditions

OSPF Link-State Advertisement Throttling

DeltaV Control Module Execution

Chapter 6. Reaching Goals: Plans and Controls

EPOCH TASK SCHEDULING IN DISTRIBUTED SERVER SYSTEMS

On-line Multi-threaded Scheduling

CS 318 Principles of Operating Systems

Integrated Scheduling: The Best of Both Worlds

LEAN PROCUREMENT.

Bounding Worst-Case Response Time for Tasks With Non-Preemptive Regions

OSPF Link-State Advertisement Throttling

Decentralized Preemptive Scheduling Across Heterogeneous Multi-core Grid Resources

OPERATIONS RESEARCH Code: MB0048. Section-A

Classifying Scheduling Policies with Respect to Unfairness in an M/GI/1

Optimization of Scheduling and Dispatching Cars on Demand

Transcription:

Comp 204: Computer Systems and Their Implementation Lecture 10: Process Scheduling 1

Today Deadlock Wait-for graphs Detection and recovery Process scheduling Scheduling algorithms First-come, first-served (FCFS) Shortest Job First (SJF) 2

Wait-For Graph Precise definition: An edge from P i to P j implies that process P i is waiting for process P j to release a resource that P i needs An edge P i P j exists in a wait-for graph if and only if the corresponding resource-allocation graph contains two edges P i R q and R q P j for some resource R q Deadlock is present if there is a cycle in the wait-for graph 3

Exercise Construct the wait-for graph that corresponds to the following resource allocation graph and say whether or not there is deadlock: R1 R2 P4 P2 P3 P1 R3 4

Corresponding Wait-For Graph P4 P2 P3 P1 5

Wait-For Graph In order to be able to effectively detect deadlock, the system must maintain the wait-for graph and run an algorithm to search for cycles, at regular intervals Issues: How often should the algorithm be invoked? Costly to do for every request May be better to do at regular intervals, or when CPU utilisation deteriorates too much How many processes will be affected by the occurrence of deadlock? One request may result in many cycles in the graph 6

Detection and Recovery Once the detection algorithm has identified a deadlock, a number of alternative strategies could be employed to recover from the situation Recovery could involve process termination All involved May be huge loss of computation One at a time Expensive: requires re-run of detection algorithm after each termination Recovery could involve preemption Choice of victim Rollback Starvation 7

Scheduling In any multiprogramming situation, processes must be scheduled The long-term scheduler (job scheduler) decides which jobs to load into memory must try to obtain a good job mix: compute-bound vs. I/Obound The short-term scheduler (CPU/process scheduler) selects next job from ready queue Determines: which process gets the CPU, when, and for how long; when processing should be interrupted Various different algorithms can be used 8

Scheduling The scheduling algorithms may be preemptive or nonpreemptive Non-preemptive scheduling: once CPU has been allocated to a process the process keeps it until it is released upon termination of the process or by switching to the waiting state The dispatcher module gives control of the CPU to the process selected by the short-term scheduler Invoked during every switch: needs to be fast CPU I/O Burst Cycle: process execution consists of a cycle of CPU execution and I/O wait So what makes a good process scheduling policy? 9

Process Scheduling Policies Several (sometimes conflicting) criteria could be considered: Maximise throughput: run as many processes as possible in a given amount of time Minimise response time: minimise amount of time it takes from when a request was submitted until the first response is produced Minimise turnaround time: move entire processes in and out of the system quickly Minimise waiting time: minimise amount of time a process spends waiting in the ready queue 10

Process Scheduling Policies Maximise CPU efficiency: keep the CPU constantly busy, e.g. run CPU-bound, not I/O bound processes Ensure fairness: give every process an equal amount of CPU and I/ O time, e.g. by not favouring any one, regardless of its characteristics Examining the above list, we can see that if the system favours one particular class of processes, then it adversely affects another, or does not make efficient use of its resources The final decision on the policy to use is left to the system designer who will determine which criteria are most important for the particular system in question 11

Process Scheduling Algorithms The short-term scheduler relies on algorithms that are based on a specific policy to allocate the CPU Process scheduling algorithms that have been widely used are: First-come, first-served (FCFS) Shortest job first (SJF) Shortest remaining time first (SRTF) Priority scheduling Round robin (RR) Multilevel queues 12

First-Come, First Served Simplest of the algorithms to implement and understand Uses a First-In-First-Out (FIFO) queue Non-preemptive algorithm that deals with jobs according to their arrival time The sooner a process arrives, the sooner it gets the CPU Once a process has been allocated the CPU it keeps until released either by termination or I/O request When a new process enters the system its PCB is linked to the end of the ready queue Process is removed from the front of the queue when the CPU becomes available, i.e. after having dealt with all the processes before it in the queue 13

Example Suppose we have three processes arriving in the following order: P 1 with CPU burst of 13 milliseconds P 2 with CPU burst of 5 milliseconds P 3 with CPU burst of 1 millisecond Using the FCFS algorithm we can view the result as a Gantt chart: P 1 P 2 P 3 0 13 18 19 14

First-Come, First Served Given the CPU burst times of the processes, we know what their individual wait times will be: 0 milliseconds for P 1 13 milliseconds for P 2 18 milliseconds for P 3 Thus, the average wait time will be (0 + 13 + 18)/3 = 10.3 milliseconds However, note that the average wait time will change if the processes arrived in the order P 2, P 3, P 1 15

Exercise What will the average wait time change to if the processes arrived in the order P 2, P 3, P 1? 16

Answer P 2 with CPU burst of 5 milliseconds P 3 with CPU burst of 1 millisecond P 1 with CPU burst of 13 milliseconds Represented as the following Gantt chart: P 2 P 3 P 1 0 5 6 19 Thus, the average wait time will be (0 + 5 + 6)/3 = 3.7 milliseconds 17

First-Come, First Served Advantages: Very easy policy to implement Disadvantages: The average wait time using a FCFS policy is generally not minimal and can vary substantially Unacceptable for use in time-sharing systems as each user requires a share of the CPU at regular intervals Processes cannot be allowed to keep the CPU for an extended length of time as this dramatically reduces system performance 18

Shortest Job First Non-preemptive algorithm that deals with processes according to their CPU burst time When the CPU becomes available it is assigned the next process that has the smallest burst time If two processes have the same burst time, FCFS is used to determine which one gets the CPU Suppose we have four processes as follows: P 1 with CPU burst of 5 milliseconds P 2 with CPU burst of 9 milliseconds P 3 with CPU burst of 6 milliseconds P 4 with CPU burst of 3 milliseconds Using the SJF algorithm we can schedule the processes as viewed in the following Gantt chart.. 19

Example P 4 P 1 P 3 P 2 0 3 8 14 23 The wait times for each process are as follows: 3 milliseconds for P 1 14 milliseconds for P 2 8 milliseconds for P 3 0 milliseconds for P 4 Thus, the average wait time is (3 + 14 + 8 + 0)/4 = 6.25 milliseconds 20

Exercise In the previous example, what would the average wait time be if we had been using the First Come, First Served algorithm? 21

Answer P 1 P 2 P 3 P 4 0 5 14 20 23 The Gantt chart above shows the wait times using FCFS The average wait time under FCFS is: (0 + 5 + 14 + 20)/4 = 9.75 milliseconds Thus, the Shortest Job First algorithm produces a shorter average wait time than FCFS 22

Shortest Job First Advantages: SJF reduces the overall average waiting time Thus SJF is provably optimal in that it gives the minimal average waiting time for a given set of processes Disadvantages: Can lead to starvation Difficult to know the burst time of the next process requesting the CPU May be possible to predict, but not guaranteed Unacceptable for use in interactive systems 23