CPU scheduling. Alternating Sequence of CPU And I/O Bursts. Histogram of CPU-burst Times. CPU Scheduler

Similar documents
Objectives. Chapter 5: Process Scheduling. Chapter 5: Process Scheduling. 5.1 Basic Concepts. To introduce CPU scheduling

Objectives. Chapter 5: CPU Scheduling. CPU Scheduler. Non-preemptive and preemptive. Dispatcher. Alternating Sequence of CPU And I/O Bursts

CPU Scheduling. Basic Concepts. Basic Concepts (2) Basic Concepts Scheduling Criteria Scheduling Algorithms Batch systems Interactive systems

CPU Scheduling. CPU Scheduling

Announcements. Basic Concepts. Histogram of Typical CPU- Burst Times. Dispatcher. CPU Scheduler. Burst Cycle. Reading

ICS Principles of Operating Systems

Chapter 5: CPU Scheduling. Operating System Concepts 8 th Edition

Chapter 5 Process Scheduling

/ Operating Systems I. Process Scheduling. Warren R. Carithers Rob Duncan

CPU Scheduling Outline

W4118 Operating Systems. Instructor: Junfeng Yang

OPERATING SYSTEMS SCHEDULING

Comp 204: Computer Systems and Their Implementation. Lecture 12: Scheduling Algorithms cont d

Scheduling. Scheduling. Scheduling levels. Decision to switch the running process can take place under the following circumstances:

Deciding which process to run. (Deciding which thread to run) Deciding how long the chosen process can run

Operating System: Scheduling

2. is the number of processes that are completed per time unit. A) CPU utilization B) Response time C) Turnaround time D) Throughput

CPU Scheduling. CSC 256/456 - Operating Systems Fall TA: Mohammad Hedayati

Main Points. Scheduling policy: what to do next, when there are multiple threads ready to run. Definitions. Uniprocessor policies

Scheduling. Yücel Saygın. These slides are based on your text book and on the slides prepared by Andrew S. Tanenbaum

PROCESS SCHEDULING ALGORITHMS: A REVIEW

Processor Scheduling. Queues Recall OS maintains various queues

Road Map. Scheduling. Types of Scheduling. Scheduling. CPU Scheduling. Job Scheduling. Dickinson College Computer Science 354 Spring 2010.

Process Scheduling CS 241. February 24, Copyright University of Illinois CS 241 Staff

CPU Scheduling. Core Definitions

OS OBJECTIVE QUESTIONS

Job Scheduling Model

A Group based Time Quantum Round Robin Algorithm using Min-Max Spread Measure

Real-Time Scheduling 1 / 39

CPU SCHEDULING (CONT D) NESTED SCHEDULING FUNCTIONS

Operating Systems. III. Scheduling.

Operating Systems Concepts: Chapter 7: Scheduling Strategies

Analysis and Comparison of CPU Scheduling Algorithms

Introduction. Scheduling. Types of scheduling. The basics

A Comparative Study of CPU Scheduling Algorithms

Scheduling Algorithms

Operating Systems Lecture #6: Process Management

Scheduling 0 : Levels. High level scheduling: Medium level scheduling: Low level scheduling

Process Scheduling. Process Scheduler. Chapter 7. Context Switch. Scheduler. Selection Strategies

Operating Systems, 6 th ed. Test Bank Chapter 7

Multiprocessor Scheduling and Scheduling in Linux Kernel 2.6

CPU Scheduling. Multitasking operating systems come in two flavours: cooperative multitasking and preemptive multitasking.

CPU Scheduling 101. The CPU scheduler makes a sequence of moves that determines the interleaving of threads.

A Review on Load Balancing In Cloud Computing 1

CS Fall 2008 Homework 2 Solution Due September 23, 11:59PM

Chapter 19: Real-Time Systems. Overview of Real-Time Systems. Objectives. System Characteristics. Features of Real-Time Systems

W4118 Operating Systems. Instructor: Junfeng Yang

REDUCING TIME: SCHEDULING JOB. Nisha Yadav, Nikita Chhillar, Neha jaiswal

A Priority based Round Robin CPU Scheduling Algorithm for Real Time Systems

Readings for this topic: Silberschatz/Galvin/Gagne Chapter 5

Operating System Tutorial

Linux Process Scheduling Policy

Chapter 1: Introduction. What is an Operating System?

A LECTURE NOTE ON CSC 322 OPERATING SYSTEM I DR. S. A. SODIYA

This tutorial will take you through step by step approach while learning Operating System concepts.

Lecture Outline Overview of real-time scheduling algorithms Outline relative strengths, weaknesses

Convenience: An OS makes a computer more convenient to use. Efficiency: An OS allows the computer system resources to be used in an efficient manner.

Real-Time Systems Prof. Dr. Rajib Mall Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

Konzepte von Betriebssystem-Komponenten. Linux Scheduler. Valderine Kom Kenmegne Proseminar KVBK Linux Scheduler Valderine Kom

Final Report. Cluster Scheduling. Submitted by: Priti Lohani

Syllabus MCA-404 Operating System - II

Performance Comparison of RTOS

Overview of Presentation. (Greek to English dictionary) Different systems have different goals. What should CPU scheduling optimize?

General Overview of Shared-Memory Multiprocessor Systems

Efficiency of Batch Operating Systems

Scheduling policy. ULK3e 7.1. Operating Systems: Scheduling in Linux p. 1

Analysis of Job Scheduling Algorithms in Cloud Computing

Operating Systems OBJECTIVES 7.1 DEFINITION. Chapter 7. Note:

Comparison between scheduling algorithms in RTLinux and VxWorks

Chapter 2: OS Overview

Types Of Operating Systems

Scheduling. Monday, November 22, 2004

Operatin g Systems: Internals and Design Principle s. Chapter 10 Multiprocessor and Real-Time Scheduling Seventh Edition By William Stallings

Chapter 1 FUNDAMENTALS OF OPERATING SYSTEM

ò Paper reading assigned for next Thursday ò Lab 2 due next Friday ò What is cooperative multitasking? ò What is preemptive multitasking?

Technical Properties. Mobile Operating Systems. Overview Concepts of Mobile. Functions Processes. Lecture 11. Memory Management.

Weight-based Starvation-free Improvised Round-Robin (WSIRR) CPU Scheduling Algorithm

Design and performance evaluation of Advanced Priority Based Dynamic Round Robin Scheduling Algorithm (APBDRR)

Load Balancing Scheduling with Shortest Load First

CHAPTER 1 INTRODUCTION

Process Scheduling II

CHAPTER 15: Operating Systems: An Overview

Chapter 3. Operating Systems

Module 6. Embedded System Software. Version 2 EE IIT, Kharagpur 1

Improving Distributed Workload Performance by Sharing Both CPU and Memory Resources

Scheduling Best-Effort and Real-Time Pipelined Applications on Time-Shared Clusters

How To Understand The Principles Of Operating Systems

Module 6. Embedded System Software. Version 2 EE IIT, Kharagpur 1

EECS 750: Advanced Operating Systems. 01/28 /2015 Heechul Yun

Module 8. Industrial Embedded and Communication Systems. Version 2 EE IIT, Kharagpur 1

CS414 SP 2007 Assignment 1

How To Understand And Understand An Operating System In C Programming

The Association of System Performance Professionals

218 Chapter 5 CPU Scheduling

Far-western University Central Office, Mahendranagar Operating System

Tasks Schedule Analysis in RTAI/Linux-GPL

Real-Time Scheduling (Part 1) (Working Draft) Real-Time System Example

TPCalc : a throughput calculator for computer architecture studies

Task Scheduling in Hadoop

A Comparative Performance Analysis of Load Balancing Algorithms in Distributed System using Qualitative Parameters

Transcription:

CPU scheduling Alternating Sequence of CPU And I/O Bursts Maximum CPU utilization is obtained by multiprogramming. CPU I/O Burst Cycle Process execution consists of a cycle of CPU execution and I/O wait. CPU burst distribution can be seen in slide 6.3. 6.1 Silberschatz and Galvin 2004 revised by Wiseman 6.2 Silberschatz and Galvin 2004 revised by Wiseman Histogram of CPU-burst Times CPU Scheduler Selects from among the processes in memory that are ready to execute, and allocates the CPU to one of them. 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. Scheduling under 1 and 4 is nonpreemptive. All other scheduling is preemptive. 6.3 Silberschatz and Galvin 2004 revised by Wiseman 6.4 Silberschatz and Galvin 2004 revised by Wiseman

Dispatcher Scheduling Criteria Dispatcher module 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 restart that program Dispatch latency time it takes for the dispatcher to stop one process and start another running. 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. 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 all output (for time-sharing environment). 6.5 Silberschatz and Galvin 2004 revised by Wiseman 6.6 Silberschatz and Galvin 2004 revised by Wiseman First-Come, First-Served (FCFS) Scheduling FCFS Scheduling (Cont.) Example: Process Burst Time 24 3 3 Suppose that the processes arrive in the order:,, The Gantt Chart for the schedule is: 0 Waiting time for = 0; = 24; = 27 Average waiting time: (0 + 24 + 27)/3 = 17 24 27 30 Suppose that the processes arrive in the order,,. The Gantt Chart for the schedule is: 0 Waiting time for = 6; = 0; = 3 Average waiting time: (6 + 0 + 3)/3 = 3 Much better than previous case. Convoy effect short process behind long process 3 6 30 6.7 Silberschatz and Galvin 2004 revised by Wiseman 6.8 Silberschatz and Galvin 2004 revised by Wiseman

Shortest-Job-First (SJF) Scheduling Example of Non-Preemptive SJF Associate with each process the length of its next CPU burst. Use these lengths to schedule the process with the shortest time. Two schemes: nonpreemptive once CPU given to the process it cannot be preempted until completes its CPU burst. Preemptive if a new process arrives with CPU burst length less than remaining time of current executing process, preempt. This scheme is know as the Shortest-Remaining-Time-First (SRTF). SRTF is optimal gives minimum average waiting time for a given set of processes. Process Arrival Time Burst Time 0.0 7 2.0 4 4.0 1 5.0 4 Gantt Chart of SJF (non-preemptive): 0 3 7 8 12 16 Average waiting time = (0 + 6 + 3 + 7)/4 = 4 6.9 Silberschatz and Galvin 2004 revised by Wiseman 6.10 Silberschatz and Galvin 2004 revised by Wiseman Example of Preemptive SJF (SRTF) Determining Length of Next CPU Burst Process Arrival Time Burst Time 0.0 7 2.0 4 4.0 1 5.0 4 Gantt Chart of SRTF (preemptive SJF): Can only estimate the length. Can be done by using the length of previous CPU bursts, using exponential averaging. 1. t n = actual lenght of n 2. τ n + 1 3. α, 0 α 1 4. Define : th = predicted value for CPU burst the next CPU burst τ n + 1 = α t n 1 + ( α) τ n 0 2 4 5 7 11 Average waiting time = (9 + 1 + 0 +2)/4 = 3 16 6.11 Silberschatz and Galvin 2004 revised by Wiseman 6.12 Silberschatz and Galvin 2004 revised by Wiseman

Examples of Exponential Averaging Example of Prediction α =0 τ n+1 = τ n Recent history does not count. α =1 τ n+1 = t n Only the actual last CPU burst counts. If we expand the formula, we get: τ n+1 = α t n +(1 - α) α t n-1 + +(1 - α ) j α t n-j + +(1 - α ) n+1 τ 0 Since both α and (1 - α) are less than or equal to 1, each successive term has less weight than its predecessor. 6.13 Silberschatz and Galvin 2004 revised by Wiseman 6.14 Silberschatz and Galvin 2004 revised by Wiseman Priority Scheduling Round Robin (RR) 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 nonpreemptive 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. Each process gets a small unit of CPU time (time quantum), usually 10-100 milliseconds. After this time has elapsed, the process is preempted and added to the end of the ready queue. If there are n processes in the ready queue and the time quantum is q, then each process gets 1/n of the CPU time in chunks of at most q time units at once. No process waits more than (n-1)q time units. Performance q large FCFS q small q must be large with respect to context switch, otherwise overhead is too high. 6.15 Silberschatz and Galvin 2004 revised by Wiseman 6.16 Silberschatz and Galvin 2004 revised by Wiseman

Example: RR with Time Quantum = 20 How a Smaller Time Quantum Increases Context Switches Process Burst Time 53 17 68 24 The Gantt Chart is: 0 20 37 57 77 97 117 121 134 154 162 Typically, higher average turnaround than SJF, but better response. 6.17 Silberschatz and Galvin 2004 revised by Wiseman 6.18 Silberschatz and Galvin 2004 revised by Wiseman Multilevel Queue Multilevel Queue Scheduling Ready queue is partitioned into separate queues: foreground (interactive) background (batch) Each queue has its own scheduling algorithm, foreground RR background FCFS Scheduling must be done between the queues. Fixed priority scheduling; i.e., serve all from foreground then from background. Possibility of starvation. Time slice each queue gets a certain amount of CPU time which it can schedule amongst its processes; e.g., 80% to foreground in RR, 20% to background in FCFS 6.19 Silberschatz and Galvin 2004 revised by Wiseman 6.20 Silberschatz and Galvin 2004 revised by Wiseman

Multilevel Feedback Queue 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 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 6.21 Silberschatz and Galvin 2004 revised by Wiseman 6.22 Silberschatz and Galvin 2004 revised by Wiseman Example of Multilevel Feedback Queue Multiple-Processor Scheduling Three queues: Q 0 time quantum 8 milliseconds Q 1 time quantum 16 milliseconds Q 2 FCFS Scheduling A new job enters queue Q 0 which is served RR. When it gains CPU, job receives 8 milliseconds. If it does not finish in 8 milliseconds, job is moved to queue Q 1. At Q 1 job is again served RR and receives 16 additional milliseconds. If it still does not complete, it is preempted and moved to queue Q 2. CPU scheduling more complex when multiple CPUs are available. Symmetric multiprocessing all of the processors run an identical copy of the same kernel, Implemented on Homogeneous processors. A mechanism for data locking should be implemented. All of UNIX versions, WindowsNT and Windows2000 are Symmetric. Asymmetric multiprocessing only one processor running the scheduler which accesses the system data structures. Processors can be unequal. alleviating the need for data sharing. Used on large clusters or Supercomputers. 6.23 Silberschatz and Galvin 2004 revised by Wiseman 6.24 Silberschatz and Galvin 2004 revised by Wiseman

Backfilling Gang Scheduling Backfilling is an asymmetric multiprocessing scheduling. Finding free nodes for the first job in the queue. If there aren't enough free nodes, the job will have to wait. However, if there are enough free nodes for another job in the queue, the free nodes will be assigned to the other job. In order to prevent starvation of jobs which use a higher number of nodes, we will require that a job selected out of order will not delay the execution of jobs which have a higher location in the queue. Gang Scheduling is also an asymmetric multiprocessing scheduling. Gang Scheduling gives a job all the processors at the same time (or none for a time slice). Gang Scheduling slices the time in a Round-Robin manner. The jobs are put into a matrix. Each column in the matrix represents a node and each row represents a time slot. The rows are executed one by one. This approach tries to minimize the rows as much as possible, so each job will get more time quanta. Very useful when most of the jobs have a lot of communication between their processes. 6.25 Silberschatz and Galvin 2004 revised by Wiseman 6.26 Silberschatz and Galvin 2004 revised by Wiseman Gang Scheduling (Cont.) Algorithm Evaluation job 1 job 3 job 2 Deterministic modeling (simulation) takes a particular predetermined workload and defines the performance of each algorithm for that workload. Queuing models Implementation job 4 Ousterhout Matrix - The jobs in successive slots are scheduled in turn in a round-robin manner. 6.27 Silberschatz and Galvin 2004 revised by Wiseman 6.28 Silberschatz and Galvin 2004 revised by Wiseman

Evaluation of CPU Schedulers by Simulation Linux Scheduling Linux has a multi level queue contains: FIFO Real-Time. RR Real-Time. Non-Real-Time scheduling as described below. Processes may migrate from one queue to another just by an explicit command. The Non-Real-Time Linux scheduler partitions time into epochs. In each epoch, every process has a time slice of how long it may run. When there are no ready processes with a time slice left, a new epoch is started. The order within the epoch is set according to the dynamic priority. The dynamic priority is a number between 100 to 140 that is set according to the nice value plus/minus bonus of 5. The bonus reflects the CPU consuming of the processes. 6.29 Silberschatz and Galvin 2004 revised by Wiseman 6.30 Silberschatz and Galvin 2004 revised by Wiseman Linux Scheduling (cont.) Windows Scheduling The calculation of the time slice is based on: The "nice" value (The range is -20 to 19). Processes that did not use up all their previous time slice transfer half of it to the new epoch. In Linux 2.6 the half of the unused time is not added. Linux 2.6 tries to recognize interactive processes. Essentially, tasks get an interactive credit when they sleep for a longtime, and lose an interactive credit when they run for a long time. Linux 2.6 will give another time slice in the same epoch to an interactive process, if the interactive process uses up its initial time slice. In Linux 2.4 the time slices were calculated in the beginning of the epoch. In Linux 2.6 the time slice is calculated when a process leaves the CPU. Windows has a multi level queue contains: Real-Time. Non-Real-Time scheduling as described below. Processes may migrate from one queue to another just by an explicit command. The "nice" value of Windows is called "thread's type". Can be: 1) high, 2) above_normal, 3) normal, 4) below_normal, 5) low. There are also some dynamic rules: Threads associated with the focus window get a triple quantum. Multi-Media threads are not always in the focus window. After an I/O wait, the priority is boosted by a factor that is inversely proportional to the speed of the I/O device. This is then decremented by one at the end of each quantum, until the original priority is reached again. Keyboard and mouse are very slow; hence contribute a big boost. 6.31 Silberschatz and Galvin 2004 revised by Wiseman 6.32 Silberschatz and Galvin 2004 revised by Wiseman