Average waiting time = [(10-1)+(1-1)+(17-2)+(5-3)]/4 = 26/4 = 6.5 msec

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

Operating System: Scheduling

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. Basic Concepts. Basic Concepts (2) Basic Concepts Scheduling Criteria Scheduling Algorithms Batch systems Interactive systems

CPU Scheduling. CPU Scheduling

CPU Scheduling Outline

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

Chapter 5 Process Scheduling

ICS Principles of Operating Systems

W4118 Operating Systems. Instructor: Junfeng Yang

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

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

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

CPU SCHEDULING (CONT D) NESTED SCHEDULING FUNCTIONS

PROCESS SCHEDULING ALGORITHMS: A REVIEW

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

CPU Scheduling. Core Definitions

OPERATING SYSTEMS SCHEDULING

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

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

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

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

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

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

Job Scheduling Model

Processor Scheduling. Queues Recall OS maintains various queues

Introduction. Scheduling. Types of scheduling. The basics

A Comparative Study of CPU Scheduling Algorithms

Operating Systems Lecture #6: Process Management

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

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

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

Operating Systems Concepts: Chapter 7: Scheduling Strategies

Analysis and Comparison of CPU Scheduling Algorithms

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

Operating Systems. III. Scheduling.

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

Comparison between scheduling algorithms in RTLinux and VxWorks

OS OBJECTIVE QUESTIONS

Scheduling Algorithms

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

CS414 SP 2007 Assignment 1

Threads Scheduling on Linux Operating Systems

Multiprocessor Scheduling and Scheduling in Linux Kernel 2.6

A Review on Load Balancing In Cloud Computing 1

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

Operating Systems, 6 th ed. Test Bank Chapter 7

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

Real-Time Scheduling 1 / 39

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

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

First-class User Level Threads

W4118 Operating Systems. Instructor: Junfeng Yang

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

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

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

OPERATING SYSTEM CONCEPTS

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

Multi-core Programming System Overview

Operating Systems. 05. Threads. Paul Krzyzanowski. Rutgers University. Spring 2015

Tasks Schedule Analysis in RTAI/Linux-GPL

Process definition Concurrency Process status Process attributes PROCESES 1.3

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

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

Linux Process Scheduling Policy

Performance Comparison of RTOS

Last Class: OS and Computer Architecture. Last Class: OS and Computer Architecture

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

Analysis of Job Scheduling Algorithms in Cloud Computing

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

Process Scheduling II

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

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

Operating System Tutorial

Syllabus MCA-404 Operating System - II

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

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

Operating System Structure

Operating Systems OBJECTIVES 7.1 DEFINITION. Chapter 7. Note:

Efficiency of Batch Operating Systems

4. Fixed-Priority Scheduling

Shared Address Space Computing: Programming

Real- Time Scheduling

Far-western University Central Office, Mahendranagar Operating System

Lecture 3 Theoretical Foundations of RTOS

EE8205: Embedded Computer System Electrical and Computer Engineering, Ryerson University. Multitasking ARM-Applications with uvision and RTX

218 Chapter 5 CPU Scheduling

Real-time scheduling algorithms, task visualization

Completely Fair Scheduler and its tuning 1

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

Final Project Report. Trading Platform Server

Exercises : Real-time Scheduling analysis

REAL TIME OPERATING SYSTEMS. Lesson-10:

Transcription:

Example of Shortest-remaining-time-first i.e. Preemptive SJF Now we add the concepts of varying arrival times and preemption to the analysis ProcessAarri Arrival TimeT Burst Time P 1 0 8 P 2 1 4 P 3 2 9 P 4 3 5 Preemptive SJF Gantt Chart P 1 P 2 P 4 P 1 P 3 0 1 5 10 17 26 Average waiting time = [(10-1)+(1-1)+(17-2)+(5-3)]/4 = 26/4 = 6.5 msec 6.1 Silberschatz, Galvin and Gagne 2013

Priority Scheduling A priority number (integer) is associated with each process The CPU is allocated to the process with the highest priority (smallest integer highest priority) Can be preemptive Can be nonpreemptive SJF is priority scheduling where priority is the inverse of predicted next CPU burst time Problem Starvation low priority processes may never execute Solution Aging as time progresses increase the priority of the process There is a rumor that when the IBM 7094 at MIT was shut down in 1973 that a low-priority process from 1967 had not yet been run. 6.2 Silberschatz, Galvin and Gagne 2013

Example of Priority Scheduling ProcessAarri Burst Time(ms)T Priority P 1 10 3 P 2 1 1 P 3 2 4 P 4 1 5 P 5 5 2 Priority scheduling Gantt Chart assuming all arrive at time 0 Average waiting time = (0+1+6+16+18)/5 = 8.2 msec 6.3 Silberschatz, Galvin and Gagne 2013

Round Robin (RR) Each process gets a small unit of CPU time (time quantum q), 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. Timer interrupts every quantum to schedule next process Performance q large FIFO q small q must be large with respect to context switch, otherwise overhead is too high 6.4 Silberschatz, Galvin and Gagne 2013

Example of RR with Time Quantum = 4 Process Burst Time P 1 24 P 2 3 P 3 3 The Gantt chart assuming all processes arrive at time 0 is: P P 2 P 3 P 1 P 1 P 1 P P 1 1 1 0 4 7 10 14 18 22 26 30 Typically, higher average turnaround than SJF, but better response q should be large compared to context switch time q usually 10ms to 100ms, context switch < 10 µsec 6.5 Silberschatz, Galvin and Gagne 2013

Time Quantum and Context Switch Time 6.6 Silberschatz, Galvin and Gagne 2013

Turnaround Time Varies With The Time Quantum 80% of CPU bursts should be shorter than q Given a time quantun of 1, where does 11.0 come from? 6.7 Silberschatz, Galvin and Gagne 2013

Multilevel Queue Ready queue is partitioned into separate queues, eg: foreground (interactive) background (batch) Process permanently in a given queue 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; i.e., 80% to foreground in RR 20% to background in FCFS 6.8 Silberschatz, Galvin and Gagne 2013

Multilevel Queue Scheduling 6.9 Silberschatz, Galvin and Gagne 2013

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 method used to determine which queue a process will enter when that process needs service 6.10 Silberschatz, Galvin and Gagne 2013

Example of Multilevel Feedback Queue Three queues: Q 0 RR with time quantum 8 milliseconds Q 1 RR time quantum 16 milliseconds 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 6.11 Silberschatz, Galvin and Gagne 2013

Thread Scheduling Distinction between user-level and kernel-level threads When threads are supported, threads are scheduled, not processes Many-to-one and many-to-many models, thread library schedules user-level threads to run on LWP Known as process-contention scope (PCS) since scheduling competition is within the process Typically done via priority set by programmer Kernel thread scheduled onto available CPU is system-contention scope (SCS) competition among all threads in system 6.12 Silberschatz, Galvin and Gagne 2013

Pthread Scheduling API allows specifying either PCS or SCS during thread creation PTHREAD_SCOPE_PROCESS schedules threads using PCS scheduling PTHREAD_SCOPE_SYSTEM schedules threads using SCS scheduling Can be limited by OS Linux and Mac OS X only allow PTHREAD_SCOPE_SYSTEM 6.13 Silberschatz, Galvin and Gagne 2013

Pthread Scheduling API #include <pthread.h> #include <stdio.h> #define NUM_THREADS 5 int main(int argc, char *argv[]) { int i, scope; pthread_t tid[num THREADS]; pthread_attr_t attr; /* get the default attributes */ pthread_attr_init(&attr); /* first inquire on the current scope */ if (pthread_attr_getscope(&attr, &scope)!= 0) else { } fprintf(stderr, "Unable to get scheduling scope\n"); if (scope == PTHREAD_SCOPE_PROCESS) printf("pthread_scope_process"); else if (scope == PTHREAD_SCOPE_SYSTEM) printf("pthread_scope_system"); else fprintf(stderr, "Illegal scope value.\n"); 6.14 Silberschatz, Galvin and Gagne 2013

Pthread Scheduling API } /* set the scheduling algorithm to PCS or SCS */ pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM); /* create the threads */ for (i = 0; i < NUM_THREADS; i++) pthread_create(&tid[i],&attr,runner,null); /* now join on each thread */ for (i = 0; i < NUM_THREADS; i++) pthread_join(tid[i], NULL); /* Each thread will begin control in this function */ void *runner(void *param) { } /* do some work... */ pthread_exit(0); 6.15 Silberschatz, Galvin and Gagne 2013