Announcements Project #2. Basic Concepts

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

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

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

CPU Scheduling. CPU Scheduling

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

ICS Principles of Operating Systems

W4118 Operating Systems. Instructor: Junfeng Yang

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

Chapter 5 Process Scheduling

CPU Scheduling Outline

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

OPERATING SYSTEMS SCHEDULING

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

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

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

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

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

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

Operating System: Scheduling

Introduction. Scheduling. Types of scheduling. The basics

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

Operating Systems. III. Scheduling.

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

Operating Systems, 6 th ed. Test Bank Chapter 7

Processor Scheduling. Queues Recall OS maintains various queues

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

Job Scheduling Model

CPU SCHEDULING (CONT D) NESTED SCHEDULING FUNCTIONS

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

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

OS OBJECTIVE QUESTIONS

A Comparative Study of CPU Scheduling Algorithms

CPU Scheduling. Core Definitions

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

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

Analysis and Comparison of CPU Scheduling Algorithms

Operating Systems Concepts: Chapter 7: Scheduling Strategies

PROCESS SCHEDULING ALGORITHMS: A REVIEW

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

Operating Systems Lecture #6: Process Management

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

Real-Time Scheduling 1 / 39

Syllabus MCA-404 Operating System - II

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

Scheduling Algorithms

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?

Multiprocessor Scheduling and Scheduling in Linux Kernel 2.6

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

Linux Process Scheduling Policy

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

Operating System Tutorial

W4118 Operating Systems. Instructor: Junfeng Yang

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

Analysis of Job Scheduling Algorithms in Cloud Computing

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

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

A Review on Load Balancing In Cloud Computing 1

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

Scheduling. Monday, November 22, 2004

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

4. Fixed-Priority Scheduling

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

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

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

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 Scheduling (Part 1) (Working Draft) Real-Time System Example

Efficiency of Batch Operating Systems

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

Operating Systems OBJECTIVES 7.1 DEFINITION. Chapter 7. Note:

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

Ready Time Observations

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

Final Report. Cluster Scheduling. Submitted by: Priti Lohani

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

Aperiodic Task Scheduling

REAL TIME OPERATING SYSTEMS. Lesson-10:

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

Real-time scheduling algorithms, task visualization

OPERATING SYSTEM - VIRTUAL MEMORY

218 Chapter 5 CPU Scheduling

Real Time Scheduling Basic Concepts. Radek Pelánek

Chapter 1 FUNDAMENTALS OF OPERATING SYSTEM

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

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

Process Scheduling II

THREADS WINDOWS XP SCHEDULING

Load Balancing in Distributed System. Prof. Ananthanarayana V.S. Dept. Of Information Technology N.I.T.K., Surathkal

Linux Scheduler. Linux Scheduler

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

CS0206 OPERATING SYSTEMS Prerequisite CS0201, CS0203

Introduction Disks RAID Tertiary storage. Mass Storage. CMSC 412, University of Maryland. Guest lecturer: David Hovemeyer.

Chapter 1 8 Essay Question Review

Small is Better: Avoiding Latency Traps in Virtualized DataCenters

Performance Comparison of RTOS

Chapter 2: OS Overview

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

Today. Intro to real-time scheduling Cyclic executives. Scheduling tables Frames Frame size constraints. Non-independent tasks Pros and cons

OPERATING SYSTEM OVERVIEW

Perfmon counters for Enterprise MOSS

Transcription:

Announcements Project #2 Is due at 6:00 PM on Friday Program #3 Posted tomorrow (implements scheduler) Reading Chapter 6 Basic Concepts CPU I/O burst cycle Process execution consists of a cycle of CPU execution and I/O wait. CPU burst distribution What are the typical burst sizes of a process s execution? 1 1

Burst Cycle Histogram of Typical CPU- Burst Times 2 2

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. Dispatcher 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. 3 3

Scheduling Criteria CPU utilization % time CPU is in use 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 (for interactive environment) Max Optimization Criteria CPU utilization throughput Min turnaround time waiting time response time 4 4

Optimization criteria non-performance related Predictability, e.g., job should run in about the same amount of time, regardless of total system load response times should not vary Fairness don t starve any processes Enforce priorities favor higher priority processes Balance resources keep all resources busy Types of Scheduling At least 4 types: long-term - add to pool of processes to be executed medium-term - add to number of processes partially or fully in main memory short-term - which available process will be executed by the processor I/O - which process s pending I/O request will be handled by an available I/O device Scheduling changes the state of a process 5 5

Medium vs. Short Term Medium-term scheduling Swaps processes between main memory and disk based on how many processes the OS wants available must consider memory management if no virtual memory (VM), so look at memory requirements of swapped out processes Short-term scheduling (dispatcher) Executes most frequently, to decide which process to execute next Invoked whenever event occurs that interrupts current process or provides an opportunity to preempt current one in favor of another Events: clock interrupt, I/O interrupt, OS call, signal Long-term scheduling Determine which programs admitted to system for processing Once admitted, program becomes a process Queued for short- or medium-term scheduler Scheduling batch jobs Can system take a new process? more processes implies less time for each existing one add job(s) when a process terminates, or if percentage of processor idle time is greater than some threshold Which job to schedule? first-come, first-serve (FCFS), or to manage overall system performance (e.g. based on priority, expected execution time, I/O requirements, etc.) 6 6

Process State Transitions New Long-term scheduling Ready, suspend Blocked, suspend Mediumterm scheduling Ready Blocked Shortterm scheduling Event wait Running Exit 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 The Gantt Chart for the schedule is: 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 7 7

FCFS Scheduling Suppose that the processes arrive in the order P 2, P 3, P 1. The Gantt chart for the schedule is: 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 Shortest-Job-First (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 process 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. Dubbed Shortest- Remaining-Time-First (SRTF). Should yield better turnaround times. SJF is optimal gives minimum average waiting time for a given set of processes. 8 8

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 Preemptive SJF (SRTF) 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 9 9

Length of Next CPU Burst Can only estimate the length. Can be done by using the length of previous CPU bursts, using exponential averaging. τ n+1 = α t n +(1 - α) τ n t n actual length of n th CPU burst τ n+1 predicted value of n+1 st CPU burst α history parameter 0 <= α <= 1 Exponential Averaging α =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. 10 10

Predicting the Next CPU Burst Length (α = 1 / 2, τ 0 = 10) Round Robin (RR) Each process gets a small unit of CPU time (time quantum). Once this time elapses, the process is preempted and placed on the back of the ready queue. If there are n processes in the ready queue and the time quantum is q, then no process waits more than (n-1)q time units. 11 11

Choosing the Quantum How to choose q? Very large: degenerates to FCFS Very small: dispatch time dominates Guideline: for better turnaround time, quantum should be slightly greater than time of typical job CPU burst. Turnaround Time Varies With The Time Quantum 12 12

Time Quantum and Context Switch Time Example RR with q = 20 Process Burst Time P 1 53 P 2 17 P 3 68 P 4 24 The Gantt chart is: 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 Typically, higher average turnaround than SJF, but better response. 13 13

Priority Scheduling A priority number (integer) is associated with each process OS schedules the process with the highest priority (smallest integer highest priority). 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. Multilevel Priority Queue Ready queue is divided into n queues, each with its own scheduling algorithm, e.g. foreground (interactive) - RR background (batch) - FCFS Scheduling 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 14 14

Multilevel Priority Scheduling Many ready queues, ordered by priority RQ0 RQ1 Dispatch CPU Release Admit. RQn Preemption Event Occurs Blocked queue Event Wait Example 15 15

Multilevel Scheduling Design PROBLEM: turnaround time for longer processes Want to avoid undue increase or starvation when new short jobs regularly enter system Solution 1: vary preemption times according to queue processes in lower priority queues have longer time slices Solution 2: promote a process to higher priority queue after it spends a certain amount of time waiting for service in its current queue, it moves up Solution 3: allocate fixed share of CPU time to jobs if a process doesn t use its share, give it to other processes variation on this idea: lottery scheduling assign a process tickets (# of tickets is share) pick random number and run the process with the winning ticket. Multilevel Feedback Queue A process can move between the various queues, implementing aging. Multilevel-feedback-queue scheduler defined by the following parameters: number of queues scheduling algorithms for each queue method to determine when to upgrade a process method to determine when to demote a process method to determine which queue a process will enter when that process needs service 16 16

Example of Multilevel Feedback Queue 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 FCFS and receives 16 additional milliseconds. If it does not complete, it is preempted and moved to queue Q 2. Multilevel Feedback Queues 17 17

Multi-Processor Scheduling Multiple processes need to be scheduled together Called gang-scheduling Allowing communicating processes to interact w/o/ waiting Try to schedule processes back to same processor Called affinity scheduling Maintain a small ready queue per processor Go to global queue if nothing local is ready Algorithm Evaluation Deterministic modeling takes a particular predetermined workload and defines the performance of each algorithm for that workload. Queueing models Simulation Implementation 18 18

UNIX System V Multilevel feedback, with RR within each priority queue 10ms preemption priority based on process type and execution history, lower value is higher priority Priority recomputed once per second, and scheduler selects new process to run UNIX System V Priority P(i) = Base + CPU(i-1)/2 + nice P(i) is priority of process j at interval i Base is base priority of process j CPU(i) = U(i)/2 + CPU(i-1)/2 U(i) is CPU use of process j in interval i exponentially weighted average CPU use of process j through interval i nice is user-controllable adjustment factor Penalizes CPU-bound processes Targets general-purpose time sharing (and interactive) environment 19 19

UNIX System V Base priority divides all processes into (non-overlapping) fixed bands of decreasing priority levels swapper, block I/O device control, file manipulation, character I/O device control, user processes Bands optimize access to block devices (disk), allow OS to respond quickly to system calls GeekOS (<= project 2) Uses priority-based, RR scheduling Each kthread has a priority Level 0 is the idle process which runs when there is no real work to be done Level 1 is for normal user processes Level 10 is the highest priority Chooses highest-priority thread that is in the ready queue (s_runqueue). 20 20

GeekOS (Project 3) Multi-level feedback scheduling Multiple queues, each denoting a higher priority scheduling class (still have priorities within each class) Queue placement policy: Thread is demoted to next lower class if it consumes all its quantum. Thread is promoted to the next higher class if it blocks. Idle thread treated specially. Solaris 2 Scheduling 21 21

Windows 2000 Priorities 22 22