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



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

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

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

CPU Scheduling Outline

CPU Scheduling. CPU Scheduling

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

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

Processor Scheduling. Queues Recall OS maintains various queues

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

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

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

Operating Systems Lecture #6: Process Management

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

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

OPERATING SYSTEMS SCHEDULING

CPU Scheduling. Core Definitions

Chapter 5 Process Scheduling

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

Operating Systems. III. Scheduling.

Job Scheduling Model

ICS Principles of Operating Systems

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

Operating Systems Concepts: Chapter 7: Scheduling Strategies

W4118 Operating Systems. Instructor: Junfeng Yang

Operating System: Scheduling

CPU SCHEDULING (CONT D) NESTED SCHEDULING FUNCTIONS

Introduction. Scheduling. Types of scheduling. The basics

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

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

Scheduling Algorithms

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

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

Multiprocessor Scheduling and Scheduling in Linux Kernel 2.6

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

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

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

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

OS OBJECTIVE QUESTIONS

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

Operating Systems, 6 th ed. Test Bank Chapter 7

Real-Time Scheduling 1 / 39

Syllabus MCA-404 Operating System - II

PROCESS SCHEDULING ALGORITHMS: A REVIEW

W4118 Operating Systems. Instructor: Junfeng Yang

Linux Process Scheduling Policy

4. Fixed-Priority Scheduling

CS414 SP 2007 Assignment 1

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

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

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

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

A Comparative Study of CPU Scheduling Algorithms

Analysis and Comparison of CPU Scheduling Algorithms

Process Scheduling II

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

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

Multi-core Programming System Overview

Linux Scheduler. Linux Scheduler

Operating System Tutorial

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

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

Operating Systems OBJECTIVES 7.1 DEFINITION. Chapter 7. Note:

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

Completely Fair Scheduler and its tuning 1

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

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

A Review on Load Balancing In Cloud Computing 1

Overview of the Linux Scheduler Framework

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

Project No. 2: Process Scheduling in Linux Submission due: April 28, 2014, 11:59pm

Tasks Schedule Analysis in RTAI/Linux-GPL

Page 1 of 5. IS 335: Information Technology in Business Lecture Outline Operating Systems

Analysis of Job Scheduling Algorithms in Cloud Computing

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

Survey of software architectures: function-queue-scheduling architecture and real time OS

SYSTEM ecos Embedded Configurable Operating System

Lecture 3 Theoretical Foundations of RTOS

218 Chapter 5 CPU Scheduling

REAL TIME OPERATING SYSTEMS. Lesson-10:

Threads Scheduling on Linux Operating Systems

ò Scheduling overview, key trade-offs, etc. ò O(1) scheduler older Linux scheduler ò Today: Completely Fair Scheduler (CFS) new hotness

Multilevel Load Balancing in NUMA Computers

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

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

Scheduling algorithms for Linux

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

Exercises : Real-time Scheduling analysis

Load Balancing Scheduling with Shortest Load First

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

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

Final Report. Cluster Scheduling. Submitted by: Priti Lohani

Task Scheduling for Multicore Embedded Devices

I/O Management. General Computer Architecture. Goals for I/O. Levels of I/O. Naming. I/O Management. COMP755 Advanced Operating Systems 1

Transcription:

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

Today Scheduling continued Multilevel queues Examples Thread scheduling 2

Question A starvation-free job-scheduling policy guarantees that no job waits indefinitely for service. Which of the following job-scheduling policies is starvation-free? a) Round-robin b) Priority queuing c) Shortest job first d) Youngest job first e) None of the above Answer: a Round Robin this gives all processes equal access to the processor. The other techniques each select some types of processes to others (e.g. short processes, high priority processes etc). 3

Question? Suppose that a scheduling algorithm favours processes that have used the least CPU time in the recent past. Why will this algorithm favour I/O-bound programs and yet not permanently starve CPUbound programs? 4

Answer It will favour the I/O-bound programs because of their relatively short CPU burst times but, the CPU-bound programs will not starve because the I/O-bound programs will relinquish the CPU relatively often to do their I/O. 5

Multilevel Queue Highest priority System processes Interactive processes Batch processes Lowest priority Student processes 6

Multilevel Queue Each queue has its own scheduling algorithm e.g. queue of foreground processes using RR and queue of batch processes using FCFS Scheduling must be done between the queues Fixed priority scheduling: serve all from one queue then another 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 queue, 20% to background queue 7

Multilevel Feedback Queue A process can move between the various queues Separates processes according to characteristics of their CPU bursts I/O-bound processes stay in high-priority queues Compute-bound processes relegated to lower priority queues Aging can be implemented to promote very long processes and hence prevent starvation Parameters to be considered for a multilevel-feedbackqueue scheduler: How many queues? Which algorithm is used for each queue? How to determine when to upgrade/demote a process to a higher/lower priority? How to determine which queue a process will enter? 8

Example Three queues: 1) RR with time quantum of 4 milliseconds 2) RR time quantum of 8 milliseconds 3) FCFS Scheduling A process at head of queue 1 gains the CPU for 4 milliseconds. If it does not finish in 4 milliseconds, it is preempted and moved to tail of queue 2 When queue 1 is empty, the process at the head of queue 2 gets the CPU for 8 milliseconds. If it does not finish, it is preempted and moved to queue 3 When queues in 1 and 2 are empty processes in queue 3 are run FCFS 9

Multilevel Queues Advantages: Flexible implementation w.r.t. movement between queues Enables short CPU-bound jobs to be prioritised and therefore processed quickly Can be preemptive or non-preemptive Disadvantages: Queues require monitoring, which is a costly activity 10

Exercise Suppose we have the following four processes all arriving at time 0 in the following order: P 1 with CPU burst of 8 milliseconds, priority 2 P 2 with CPU burst of 2 milliseconds, priority 1 P 3 with CPU burst of 5 millisecond, priority 3 P 4 with CPU burst of 4 milliseconds, priority 2 Which of the following algorithms gives the minimum average waiting time: SJF, Priority, RR (using a time quantum of 2 milliseconds)? 11

Answer - SJF SJF: P 1 CPU: 8 ms, priority 2 P 2 CPU: 2 ms, priority 1 P 3 CPU: 5 ms, priority 3 P 4 CPU: 4 ms, priority 2 P 2 P 4 P 3 P 1 0 2 6 11 19 Average waiting time is (11 + 0 + 6 + 2)/4 = 4.75 milliseconds 12

Answer - Priority Priority: P 1 CPU: 8 ms, priority 2 P 2 CPU: 2 ms, priority 1 P 3 CPU: 5 ms, priority 3 P 4 CPU: 4 ms, priority 2 P 2 P 1 P 4 P 3 0 2 10 14 19 Average waiting time is (2 + 0 + 14 + 10)/4 = 6.5 milliseconds 13

Answer - RR RR: P 1 CPU: 8 ms, priority 2 P 2 CPU: 2 ms, priority 1 P 3 CPU: 5 ms, priority 3 P 4 CPU: 4 ms, priority 2 P 1 P 2 P 3 P 4 P 1 P 3 P 4 P 1 P 3 P 1 0 2 4 6 8 10 12 14 16 17 19 Average waiting time is ((17-6) + 2 + (16-4) + (12-2))/4 = 8.75 milliseconds Thus, SJF gives the shortest average waiting time here 14

Scheduling Example Windows XP Priorities are in range 0-31 Where 31 is highest priority! A new process is given one of the following base priorities IDLE (4) BELOW_NORMAL (6) NORMAL (8) ABOVE_NORMAL (10) HIGH (13) REALTIME (24) For NORMAL processes the foreground process (currently active window) has its time quantum lengthened Each process starts with a single thread, although more may be created Thread scheduling is handled by kernel 15

Windows XP Threads Thread priorities divided into Variable class (0-15) Real-time class (16-31) Threads also have processor affinity CPUs may be real or virtual (hyper-threading) Thread queue for each priority Dispatcher scans queues from highest to lowest to find thread which is Ready to run Has affinity for CPU which is available If no thread found, idle thread is executed 16

Windows XP Scheduling A thread can be pre-empted if a higher-priority real-time thread becomes ready If time-slice of normal class thread expires, its priority is lowered When I/O or event wait completes for a normal class thread, priority is increased Increase is greater for slow I/O (e.g. keybd) Thread associated with active window also gets priority increased 17

Linux Scheduling The Linux scheduler is a pre-emptive priority-based algorithm Real-time tasks are distinguished from other tasks through the use of priorities The scheduler assigns longer time quanta to higherpriority tasks and shorter time quanta to lower-priority tasks When the time-slice for a task expires, it is not eligible to be run again until all other tasks have used up their time quanta Priorities are dynamically recalculated when time-slice expires 18

Java Scheduling The JVM has a loosely-defined scheduling policy based on priorities It is possible for a lower-priority thread to continue to run even as a higher-priority thread becomes runnable, though some systems may support preemption Using time-slicing, a thread runs until either: Its time quantum expires It blocks for I/O It exits its run() method 19

Java Thread Priorities A thread is given a default priority, between 1 and 10, when created The priority will be the same as the thread that created it This priority remains constant unless explicitly changed by the program setpriority() method 20

End of Section Operating systems concepts: communicating sequential processes; mutual exclusion, resource allocation, deadlock; process management and scheduling. Concurrent programming in Java: Java threads; The Producer-Consumer problem. Next section: Memory Management 21