Round Robin (RR) ACSC 271 Operating Systems. RR Example. RR Scheduling. Lecture 9: Scheduling Algorithms

Similar documents
Chapter 6: CPU Scheduling

Chapter 5: CPU Scheduling

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

Chapter 5 CPU scheduling

CS307: Operating Systems

Operating Systems CS 323 Ms. Ines Abbes

Chapter 5 Scheduling

CPU Scheduling. Basic Concepts. Histogram of CPU-burst Times. Dispatcher. CPU Scheduler. Alternating Sequence of CPU and I/O Bursts

Job Scheduling. CS170 Fall 2018

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

Chapter 5: Process Scheduling

Chapter 5: CPU Scheduling

Chapter 5: Process Scheduling

CSE 4/521 Introduction to Operating Systems

Chapter 5 Process Scheduling

Chapter 6: CPU Scheduling. Operating System Concepts 9 th Edition

Chapter 6: CPU Scheduling

Process Concept Process in Memory Process State new running waiting ready terminated Diagram of Process State

Properties of Processes

CPU Scheduling. Operating Systems (Fall/Winter 2018) Yajin Zhou ( Zhejiang University

Chapter 6: CPU Scheduling. Operating System Concepts 9 th Edition

Chapter 6: CPU Scheduling

Chapter 6: CPU Scheduling. Operating System Concepts 9 th Edition

Chapter 6: CPU Scheduling

Scheduling. Today. Next Time Process interaction & communication

CS370 Operating Systems

CPU Scheduling Algorithms

Chapter 6: CPU Scheduling. Operating System Concepts 9 th Edition

Chapter 5: CPU Scheduling

CHAPTER 2: PROCESS MANAGEMENT

CPU Scheduling: Objectives

CS370 Operating Systems

Chapter 6: CPU Scheduling. Operating System Concepts 9 th Edition

CPU Scheduling. Daniel Mosse. (Most slides are from Sherif Khattab and Silberschatz, Galvin and Gagne 2013)

LECTURE 3:CPU SCHEDULING

CPU Scheduling (Part II)

Last class: Today: CPU Scheduling. CPU Scheduling Algorithms and Systems

Lecture 5 / Chapter 6 (CPU Scheduling) Basic Concepts. Scheduling Criteria Scheduling Algorithms

Multithreaded Programming

Practice Exercises 305

ALL the assignments (A1, A2, A3) and Projects (P0, P1, P2) we have done so far.

Lecture 2 Process Management

Course Syllabus. Operating Systems

TDIU25: Operating Systems II. Processes, Threads and Scheduling

Processes and Threads

CISC 7310X. C05: CPU Scheduling. Hui Chen Department of Computer & Information Science CUNY Brooklyn College. 3/1/2018 CUNY Brooklyn College

CPU Scheduling. CSE 2431: Introduction to Operating Systems Reading: Chapter 6, [OSC] (except Sections )

Ch 4 : CPU scheduling

Assignment 3 (Due date: Thursday, 10/15/2009, in class) Part One: Provide brief answers to the following Chapter Exercises questions:

Scheduling in the Supermarket

Supplementary Materials on Multilevel Feedback Queue

Process- Concept &Process Scheduling OPERATING SYSTEMS

by Maria Lima Term Paper for Professor Barrymore Warren Mercy College Division of Mathematics and Computer Information Science

Start of Lecture: February 10, Chapter 6: Scheduling

CPU Scheduling. Rab Nawaz Jadoon. Assistant Professor DCS. Pakistan. COMSATS, Lahore. Department of Computer Science

Lecture 17: Threads and Scheduling. Thursday, 05 Nov 2009

CSC 716 Advanced Operating System Fall 2007 Exam 1. Answer all the questions. The maximum credit for each question is as shown.

8: Scheduling. Scheduling. Mark Handley

Processes. CS 475, Spring 2018 Concurrent & Distributed Systems

Scheduling. Today. Next Time. ! Introduction to scheduling! Classical algorithms. ! Process interaction & communication

Operating Systems. Scheduling

Operating System Concepts Ch. 5: Scheduling

Chapter 5: CPU Scheduling. Operating System Concepts 9 th Edit9on

OPERATING SYSTEMS CS3502 Spring Processor Scheduling. Chapter 5

Lecture Topics. Announcements. Today: Uniprocessor Scheduling (Stallings, chapter ) Next: Advanced Scheduling (Stallings, chapter

Operating Systems Unit 3

Titolo presentazione. Scheduling. sottotitolo A.Y Milano, XX mese 20XX ACSO Tutoring MSc Eng. Michele Zanella

CS370 Operating Systems

CPU Scheduling. Schedulers. CPSC 313: Intro to Computer Systems. Intro to Scheduling. Schedulers in the OS

Operating Systems CMPSCI 377 Spring Mark Corner University of Massachusetts Amherst

Scheduling. Multi-processing. Process Characterization. time. ...makes use of idle. COS450-F18-05-Scheduling - October 8, 2018

CSC Operating Systems Spring Lecture - XII Midterm Review. Tevfik Ko!ar. Louisiana State University. March 4 th, 2008.

Uniprocessor Scheduling. Basic Concepts Scheduling Criteria Scheduling Algorithms. Three level scheduling

CPU Scheduling. The scheduling problem: When do we make decision? - Have K jobs ready to run - Have N 1 CPUs - Which jobs to assign to which CPU(s)

Introduction to Operating Systems Prof. Chester Rebeiro Department of Computer Science and Engineering Indian Institute of Technology, Madras

Chap 7, 8: Scheduling. Dongkun Shin, SKKU

CS3733: Operating Systems

Operating Systems. Lecture Process Scheduling. Golestan University. Hossein Momeni

COSC243 Part 2: Operating Systems

Announcements. Program #1. Program #0. Reading. Is due at 9:00 AM on Thursday. Re-grade requests are due by Monday at 11:59:59 PM.

Scheduling of processes

ECE 7650 Scalable and Secure Internet Services and Architecture ---- A Systems Perspective. Part I: Operating system overview: Processes and threads

Preview. Process Scheduler. Process Scheduling Algorithms for Batch System. Process Scheduling Algorithms for Interactive System

Chap 7, 8: Scheduling. Dongkun Shin, SKKU

Last Class: Processes

W4118: advanced scheduling

CS 318 Principles of Operating Systems

CS 326: Operating Systems. CPU Scheduling. Lecture 6

UNIT 2 Basic Concepts of CPU Scheduling. UNIT -02/Lecture 01

OPERATING SYSTEMS. UNIT II Sections A, B & D. An operating system executes a variety of programs:

CS418 Operating Systems

Operating Systems. Process scheduling. Thomas Ropars.

Scheduling. Scheduling 1/51

UNIT - II PROCESS MANAGEMENT

3. CPU Scheduling. Operating System Concepts with Java 8th Edition Silberschatz, Galvin and Gagn

CS370 Operating Systems

Scheduling. Scheduling 1/51

Scheduling Policies. Threads Library. Lightweight Processes

Project 2: CPU Scheduling Simulator

Processes. Overview. Processes. Process Creation. Process Creation fork() Processes. CPU scheduling. Pål Halvorsen 21/9-2005

Transcription:

Round Robin (RR) ACSC 271 Operating Systems Lecture 9: Scheduling Algorithms 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 FIFO q small q must be large with respect to context switch, otherwise overhead is too high Slide 1 C.Markides ACSC 271: Operating Systems 03/12/2017 Slide 2 C.Markides ACSC 271: Operating Systems 03/12/2017 RR Example Process Burst Time P 1 24 P 2 3 P 3 3 Consider a time quantum q of 4ms. The Gantt Chart is thus given P 1 P 2 P 3 P 1 P 1 P 1 P 1 P 1 0 4 7 10 14 18 22 26 30 Slide 3 C.Markides ACSC 271: Operating Systems 03/12/2017 RR Scheduling The waiting time for P1 is 10 4 = 6. The waiting time for P2 is 4 and the waiting time for P3 is 7. The average waiting time is 17/3 = 5.66 milliseconds. The average turnaround time is 30/3 = 10 milliseconds. Typically, higher average turnaround than SJF, but better response. Slide 4 C.Markides ACSC 271: Operating Systems 03/12/2017

RR Example II Process Burst Time P 1 53 P 2 17 P 3 68 P 4 24 Consider a time quantum q of 20 ms. The Gantt Chart is thus given Time Quantum and Context Switch Time Consider switching between processes. Result: context switch 10%, then 10% is spent on context switching. Slide 5 C.Markides ACSC 271: Operating Systems 03/12/2017 Slide 6 C.Markides ACSC 271: Operating Systems 03/12/2017 Turnaround Time Varies With The Time Quantum Avg. turnaround time, does not improve by increasing the timequantum. Rule: 80% of the CPU bursts should be shorter than the time quantum. Slide 7 C.Markides ACSC 271: Operating Systems 03/12/2017 Multilevel Queue Ready queue is partitioned into separate queues: foreground (interactive processes) background (batch processes) 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 Slide 8 C.Markides ACSC 271: Operating Systems 03/12/2017

Multilevel Queue Scheduling 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 Slide 9 C.Markides ACSC 271: Operating Systems 03/12/2017 Slide 10 C.Markides ACSC 271: Operating Systems 03/12/2017 Multilevel Feedback Queue Example Three queues: Q0 RR with time quantum 8 milliseconds Q1 RR time quantum 16 milliseconds Q2 FCFS Scheduling A new job enters queue Q0 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 Q1. At Q1 job is again served FCFS and receives 16 additional milliseconds. If it still does not complete, it is preempted and moved to queue Q2. Slide 11 C.Markides ACSC 271: Operating Systems 03/12/2017 Multilevel Feedback Queues Slide 12 C.Markides ACSC 271: Operating Systems 03/12/2017

Thread Scheduling Distinction between user-level and kernel-level threads 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 Kernel thread scheduled onto available CPU is system-contention scope (SCS) competition among all threads in system 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. Slide 13 C.Markides ACSC 271: Operating Systems 03/12/2017 Slide 14 C.Markides ACSC 271: Operating Systems 03/12/2017 Pthread Scheduling API #include <pthread.h> #include <stdio.h> #define NUM THREADS 5 int main(int argc, char *argv[]) { int i; pthread t tid[num THREADS]; pthread attr t attr; /* get the default attributes */ pthread attr init(&attr); /* set the scheduling algorithm to PROCESS or SYSTEM */ pthread attr setscope(&attr, PTHREAD SCOPE SYSTEM); /* set the scheduling policy - FIFO, RT, or OTHER */ pthread attr setschedpolicy(&attr, SCHED OTHER); /* create the threads */ for (i = 0; i < NUM THREADS; i++) pthread create(&tid[i],&attr,runner,null); Pthread Scheduling API /* 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) { printf("i am a thread\n"); pthread exit(0); } Slide 15 C.Markides ACSC 271: Operating Systems 03/12/2017 Slide 16 C.Markides ACSC 271: Operating Systems 03/12/2017

Multiple-Processor Scheduling CPU scheduling more complex when multiple CPUs are available Homogeneous processors within a multiprocessor Asymmetric multiprocessing only one processor accesses the system data structures, alleviating the need for data sharing Symmetric multiprocessing (SMP) each processor is self-scheduling, all processes in common ready queue, or each has its own private queue of ready processes Processor affinity process has affinity for processor on which it is currently running soft affinity hard affinity Slide 17 C.Markides ACSC 271: Operating Systems 03/12/2017 Multicore Processors Recent trend to place multiple processor cores on same physical chip Faster and consume less power Multiple threads per core also growing Takes advantage of memory stall to make progress on another thread while memory retrieve happens Slide 18 C.Markides ACSC 271: Operating Systems 03/12/2017 Windows 7/10 Scheduling Windows implements a priority-driven, preemptive scheduling system at least one of the highest priority runnable (ready) threads always runs Disadvantage Certain high-priority threads ready to run might be limited by the processors on which they might be allowed or preferred to run on, a phenomenon called processor affinity. Slide 19 C.Markides ACSC 271: Operating Systems 03/12/2017 Windows 7/10 Thread Scheduling After a thread is selected to run, it runs for an amount of time called a quantum. A quantum is the length of time a thread is allowed to run before another thread at the same priority level is given a turn to run. Quantum values can vary from system to system and process to process for any of three reasons: System configuration Foreground and background process Use of the job object to alter the quantum. Slide 20 C.Markides ACSC 271: Operating Systems 03/12/2017

Windows 7/10 Priorities Thread priority levels are assigned from two different perspectives: those of the Windows API and those of the Windows kernel. The Windows API first organizes processes by the priority class to which they are assigned at creation: Real-time (4), High (3), Above Normal (7), Normal (2), Below Normal (5), and Idle (1). It then assigns a relative priority of the individual threads within those processes. Priority delta that is applied to the process base priority: Time-critical (15), Highest (2), Above-normal (1), Normal (0), Below-normal ( 1), Lowest ( 2), and Idle ( 15). Windows 7/10 Kernel Priorities Slide 21 C.Markides ACSC 271: Operating Systems 03/12/2017 Slide 22 C.Markides ACSC 271: Operating Systems 03/12/2017 Windows 7/10 Priorities Client versions of Windows incorporate a service called the Multimedia Class Scheduler Service (MMCSS), whose purpose is to ensure glitch-free multimedia playback for applications that register with it. MMCSS works by defining several tasks, including the following: Audio Capture Distribution Games Playback Pro Audio Window Manager To remedy skipping and other audio glitches have been a common source of irritation among Windows users in the past, and the usermode audio stack in Windows makes the situation worse because it offers even more chances for pre-emption. Linux Scheduling Constant order O(1) scheduling time Two priority ranges: time-sharing and realtime Real-time range from 0 to 99 and nice value from 100 to 140. Slide 23 C.Markides ACSC 271: Operating Systems 03/12/2017 Slide 24 C.Markides ACSC 271: Operating Systems 03/12/2017