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



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

CPU Scheduling. CPU Scheduling

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

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

ICS Principles of Operating Systems

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

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

CPU Scheduling Outline

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

Chapter 5 Process Scheduling

OPERATING SYSTEMS SCHEDULING

W4118 Operating Systems. Instructor: Junfeng Yang

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

Operating System: Scheduling

Processor Scheduling. Queues Recall OS maintains various queues

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

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

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

Operating Systems. III. Scheduling.

CPU Scheduling. Core Definitions

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

CPU SCHEDULING (CONT D) NESTED SCHEDULING FUNCTIONS

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

Introduction. Scheduling. Types of scheduling. The basics

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

Operating Systems Lecture #6: Process Management

Operating Systems Concepts: Chapter 7: Scheduling Strategies

Scheduling Algorithms

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

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

OS OBJECTIVE QUESTIONS

Job Scheduling Model

PROCESS SCHEDULING ALGORITHMS: A REVIEW

Multiprocessor Scheduling and Scheduling in Linux Kernel 2.6

Operating Systems, 6 th ed. Test Bank Chapter 7

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

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

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

Real-Time Scheduling 1 / 39

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

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

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

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

Analysis and Comparison of CPU Scheduling Algorithms

A Comparative Study of CPU Scheduling Algorithms

Linux Process Scheduling Policy

W4118 Operating Systems. Instructor: Junfeng Yang

Syllabus MCA-404 Operating System - II

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

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

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

Operating System Tutorial

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

4. Fixed-Priority Scheduling

Scheduling. Monday, November 22, 2004

A Review on Load Balancing In Cloud Computing 1

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

Comparison between scheduling algorithms in RTLinux and VxWorks

Linux O(1) CPU Scheduler. Amit Gud amit (dot) gud (at) veritas (dot) com

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

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

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

Analysis of Job Scheduling Algorithms in Cloud Computing

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

Devices and Device Controllers

Linux scheduler history. We will be talking about the O(1) scheduler

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

Operating Systems OBJECTIVES 7.1 DEFINITION. Chapter 7. Note:

Real-Time Software. Basic Scheduling and Response-Time Analysis. René Rydhof Hansen. 21. september 2010

CS414 SP 2007 Assignment 1

REAL TIME OPERATING SYSTEMS. Lesson-10:

Threads Scheduling on Linux Operating Systems

Lecture 3 Theoretical Foundations of RTOS

Far-western University Central Office, Mahendranagar Operating System

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

Efficiency of Batch Operating Systems

218 Chapter 5 CPU Scheduling

Overview of the Linux Scheduler Framework

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

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

Linux Block I/O Scheduling. Aaron Carroll December 22, 2007

Final Report. Cluster Scheduling. Submitted by: Priti Lohani

Operating Systems 4 th Class

Completely Fair Scheduler and its tuning 1

Tasks Schedule Analysis in RTAI/Linux-GPL

Thomas Fahrig Senior Developer Hypervisor Team. Hypervisor Architecture Terminology Goals Basics Details

Process Scheduling II

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

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.

Exercises : Real-time Scheduling analysis

Linux Scheduler. Linux Scheduler

Operating System Aspects. Real-Time Systems. Resource Management Tasks

Real-time scheduling algorithms, task visualization

Load Balancing Scheduling with Shortest Load First

Aperiodic Task Scheduling

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

CS 377: Operating Systems. Outline. A review of what you ve learned, and how it applies to a real operating system. Lecture 25 - Linux Case Study

Task Attribute-Based Scheduling - Extending Ada s Support for Scheduling

Performance Comparison of RTOS

Transcription:

Basic Concepts Scheduling Criteria Scheduling Algorithms Batch systems Interactive systems Based on original slides by Silberschatz, Galvin and Gagne 1 Basic Concepts CPU I/O Burst Cycle Process execution consists of a cycle of CPU execution and I/O wait. CPU-Bound Processes I/O-Bound Processes 2 Basic Concepts (2) Maximum CPU utilization obtained with multiprogramming Different part of the systems can be active simultaneously allowing parallel execution of processes The scheduling algorithm should mix appropriately CPU-bound and I/O-Bound Processes 3 1

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 in different situations Non-preemptive scheduling The running process terminates The running process performs an I/O operation or waits for an event Preemptive scheduling The running process has exhausted its time slice A process A transits from blocked to ready and is considered more important than process B that is currently running 4 Dispatcher Dispatcher module gives control of the CPU to the process selected by the short-term scheduler; this involves: Context Switch 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. Context-switches should be minimized 5 Type of scheduling Batch Systems Maximize the resource utilization Interactive Systems Minimize response times Real-Time Systems Meet Temporal Constraints 6 2

General Fairness Load Balancing Objectives Batch Systems CPU utilization (% of time the CPU is executing processes) Throughput (# of processes executed per time unit) Turnaround time (amount of time to execute a particular process) Interactive Systems Response time amount of time it takes from when a request was submitted until the first response is produced, not output Real-Time Systems Temporal Constraints Avoid data loss Avoid Quality of Service (QoS) degradation 7 Scheduling for Batch Systems FCFS Firs-Come First-Served SJF Shortest Job First SRJF Shortest Remaining Job First 8 First-Come, First-Served (FCFS) Process Burst Time P 1 24 P 2 3 P 3 3 Suppose that the processes arrive in the order: P 1, P 2, P 3 P 1 P 2 P 3 0 24 27 30 Waiting time for P 1 = 0; P 2 = 24; P 3 = 27 Average waiting time: (0 + 24 + 27)/3 = 17 9 3

FCFS (Cont.) Suppose that the processes arrive in the order P 2, P 3, P 1. P 2 P 3 P 1 0 3 6 30 Waiting time for P 1 = 6; P 2 = 0 ; P 3 = 3 Average waiting time: (6 + 0 + 3)/3 = 3 Much better than previous case. Convoy effect short process behind long process 10 Shortest-Job-First (SJR) Associate with each process the length of its next CPU burst. Use these lengths to schedule the process with the shortest time. Two schemes: Non-preemptive once CPU given to the process it cannot be preempted until completes its CPU burst. Preemptive (Shortest-Remaining-Time-First or SRTF). if a new process arrives with CPU burst length less than remaining time of current executing process, preempt. This scheme is know as the SJF is optimal gives minimum average waiting time for a given set of processes that are simultaneously available. 11 Example of Non-Preemptive SJF Process Arrival Time Burst Time P 1 0.0 7 P 2 2.0 4 P 3 4.0 1 P 4 5.0 4 SJF (non-preemptive) P 1 P 3 P 2 P 4 0 3 7 8 12 16 Average waiting time = (0 + 6 + 3 + 7)/4 = 4 12 4

Example of Preemptive SJF (SRJF) Process Arrival Time Burst Time P 1 0.0 7 P 2 2.0 4 P 3 4.0 1 P 4 5.0 4 SJF (preemptive) P 1 P 2 P 3 P 2 P 4 P 1 0 2 4 5 7 11 16 Average waiting time = (9 + 1 + 0 +2)/4 = 3 13 Scheduling for Interactive Systems Round-Robin (RR) Priority-based Shortest Process Next Approximated SJF Multi-level 14 Round Robin (RR) Each process gets a small unit of CPU time (time quantum). After this time has elapsed, the process is preempted and added to the end of the ready queue. n processes in the ready queue; time quantum = q 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 FIFO q small q must be large with respect to context switch, otherwise overhead is too high. 15 5

Example of RR with Time Quantum = 20 Process Burst Time P 1 53 P 2 17 P 3 68 P 4 24 P 1 P 2 P 3 P 4 P 1 P 3 P 4 P 1 P 3 P 3 0 20 37 57 77 97 117 121 134 154 162 16 Time Quantum and Perfomance Time quantum impacts on Number of Context Switches Average Response Time RR is fair by definition All processes are given the same chances 17 Priority Scheduling A priority number (integer) is associated with each process Static vs. Dynamic Priority The CPU is allocated to the process with the highest priority (smallest integer highest priority). Preemptive vs.non-preemptive SJF (SRJF) is a priority scheduling where priority is the predicted (remaining) CPU burst time. Problem Starvation low priority processes may never execute. Solution Aging as time progresses increase the priority of the process. Classes of priority 18 6

Real-Time Scheduling Soft real-time computing requires that critical processes receive priority over less fortunate ones. Hard real-time systems required to complete a critical task within a guaranteed amount of time. Rate Monotonic Earliest Deadline First 19 Rate Monotonic Scheduling A priority is assigned based on the inverse of its period Shorter periods = higher priority; Longer periods = lower priority P 1 (T=50 ms), P 2 (T=100 ms) P 1 assigned a higher priority than P 2. 20 Earliest Deadline First Scheduling Priorities are assigned according to deadlines: the earlier the deadline, the higher the priority; the later the deadline, the lower the priority P1: p=50 ms, t=25 ms t/p=0.50 P2: p=80 ms t=35 ms t/p=0.44 21 7

Multilevel Queue 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 Example: 80% to foreground in RR; 20% to background in FCFS 22 Multilevel Queue Scheduling 23 Multilevel Feedback Queue 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 24 8

Example of Multilevel Feedback Queue Three queues: Q 0 time quantum 8 ms Q 1 time quantum 16 ms Q 2 FCFS Scheduling A new job enters queue Q 0 which is served FCFS. 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 FCFS and receives 16 additional milliseconds. If it still does not complete, it is preempted and moved to queue Q 2. 25 Operating System Examples Windows XP scheduling Linux scheduling 26 Windows XP Scheduling Thread scheduling based on Priority Preemption Time slice A thread is execute until one of the following event occurs The thread has terminated its execution The thread has exhausted its assigned time slice The has executed a blocking system call A thread higher-priority thread has entered the ready queue 27 9

Kernel Priorities Kernel priority scheme: 32 priority levels Real-time class (16-31) Variable class (1-15) Memory management thread (0) A different queue for each priority level Queues are scanned from higher levels to lower levels When no thread is found a special thread (idle thread) is executed 28 Win32 API priorities API Priority classes REALTIME_PRIORITY_CLASS HIGH_PRIORITY_CLASS ABOVE_NORMAL_PRIORITY_CLASS NORMAL_PRIORITY_CLASS BELOW_NORMAL_PRIORITY_CLASS IDLE_PRIORITY_CLASS Relative Priority TIME_CRITICAL HIGHEST ABOVE_NORMAL NORMAL BELOW_NORMAL LOWEST IDLE Real-time Class Variable Class Variable Class Variable Class Variable Class Variable Class 29 Windows XP Priorities Default Base Priority 30 10

Class Priority Management A thread is stopped as soon as its time slice is exhausted Variable Class If a thread stops because time slice is exhausted, its priority level is decreased If a thread exits a waiting operation, its priority level is increased waiting for data from keyboard, mouse significant increase Waiting for disk operations moderate increase Background/Foreground processes The time slice of the foreground process is increased (typically by a factor 3) 31 Linux Scheduling Task scheduling based on Priority levels Preemption Time slices Two priority ranges: real-time and time-sharing Real-time range from 0 to 99 Nice range from 100 to 140 The time-slice length depends on the priority level 32 Priorities and Time-slice length 33 11

RunQueue The runqueue consists of two different arrays Active array Expired array 34 Priority Calculation Real time tasks have static priority Time-sharing tasks have dynamic priority Based on nice value + 5 + 5 depends on how much the task is interactive Tasks with low waiting times are assumed to be scarcely interactive Tasks with large waiting times are assumed to be highly interactive Priority re-computation is carried out every time a task has exhausted its time slice 35 Questions? 36 12