Introducing CPU Scheduling Algorithms: The Photocopier Scenario

Similar documents
Scheduling of processes

Uniprocessor Scheduling. Aim of Scheduling

Uniprocessor Scheduling. Aim of Scheduling. Types of Scheduling. Long-Term Scheduling. Chapter 9. Response time Throughput Processor efficiency

Uniprocessor Scheduling. Chapter 9

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

A Java-based Computer Simulator and its Applications

OPERATING SYSTEMS CS3502 Spring Processor Scheduling. Chapter 5

1.1 CPU I/O Burst Cycle

Chapter 9. Uniprocessor Scheduling

CPU Scheduling (1) CPU Scheduling (Topic 3) CPU Scheduling (2) CPU Scheduling (3) Resources fall into two classes:

Today s class. Scheduling. Informationsteknologi. Tuesday, October 9, 2007 Computer Systems/Operating Systems - Class 14 1

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

Subject Name: OPERATING SYSTEMS. Subject Code: 10EC65. Prepared By: Kala H S and Remya R. Department: ECE. Date:

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.

Last Class: Processes

Operating System Concepts Ch. 5: Scheduling

Chapter 9 Uniprocessor Scheduling

Ch 4 : CPU scheduling

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

Scheduling. The Basics

COSC243 Part 2: Operating Systems

Review. Preview. Three Level Scheduler. Scheduler. Process behavior. Effective CPU Scheduler is essential. Process Scheduling

Uniprocessor Scheduling

Process Scheduling. Copyright : University of Illinois CS 241 Staff

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

CS418 Operating Systems

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

Operating Systems. Scheduling

CSL373: Lecture 6 CPU Scheduling

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

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

Operating Systems ECE344. Ding Yuan

Chapter 5: CPU Scheduling

Interactive Scheduling

Two Level Scheduling. Interactive Scheduling. Our Earlier Example. Round Robin Scheduling. Round Robin Schedule. Round Robin Schedule

CPU scheduling. Alternating sequence of CPU and I/O bursts. P a g e 31

Process- Concept &Process Scheduling OPERATING SYSTEMS

CSCE Operating Systems Scheduling. Qiang Zeng, Ph.D. Fall 2018

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

CSE120 Principles of Operating Systems. Prof Yuanyuan (YY) Zhou Scheduling

CS3733: Operating Systems

Multiprocessor and Real- Time Scheduling. Chapter 10

Scheduling. Scheduling. Scheduling. Scheduling Criteria. Priorities. Scheduling

Properties of Processes

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

CPU Scheduling Algorithms

Processes. CS 475, Spring 2018 Concurrent & Distributed Systems

OPERATING SYSTEMS. After A.S.Tanenbaum, Modern Operating Systems, 3rd edition. Uses content with permission from Assoc. Prof. Florin Fortis, PhD

CSE 120. Summer, Inter-Process Communication (IPC) Day 3. Inter-Process Communication (IPC) Scheduling Deadlock. Instructor: Neil Rhodes

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

Course Syllabus. Operating Systems

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

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

Operating Systems Unit 3

Starting the Threads

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

Announcements. Reading. Project #1 due in 1 week at 5:00 pm Scheduling Chapter 6 (6 th ed) or Chapter 5 (8 th ed) CMSC 412 S14 (lect 5)

Operating Systems: Quiz2 December 15, Class: No. Name:

Start of Lecture: February 10, Chapter 6: Scheduling

CSE 120 Principles of Operating Systems Spring 2017

Process behavior. Categories of scheduling algorithms.

Scheduling. Multiple levels of scheduling decisions. Classes of Schedulers. Scheduling Goals II: Fairness. Scheduling Goals I: Performance

Unit 3 : Process Management

Processes, Execution, and State. What is CPU Scheduling? Goals and Metrics. Rectified Scheduling Metrics. CPU Scheduling: Proposed Metrics 4/6/2016

SMD149 - Operating Systems

Scheduling in the Supermarket

Multi-Level Feedback Queues

Last Class: CPU Scheduling! Adjusting Priorities in MLFQ!

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

Frequently asked questions from the previous class survey

A CPU Scheduling Algorithm Simulator

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)

CSE 451: Operating Systems Winter Module 10 Scheduling

CS 571 Operating Systems. Midterm Review. Angelos Stavrou, George Mason University

A COMPARATIVE STUDY OF CPU SCHEDULING POLICIES IN OPERATING SYSTEMS

Announcements. Program #1. Reading. Due 2/15 at 5:00 pm. Finish scheduling Process Synchronization: Chapter 6 (8 th Ed) or Chapter 7 (6 th Ed)

CSE 120 Principles of Operating Systems

Topic 4 Scheduling. The objective of multi-programming is to have some process running at all times, to maximize CPU utilization.

Operating Systems. Process scheduling. Thomas Ropars.

An Improved Priority Dynamic Quantum Time Round-Robin Scheduling Algorithm

Sample Questions. Amir H. Payberah. Amirkabir University of Technology (Tehran Polytechnic)

Remaining Contemplation Questions

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

CSE 120. Fall Lecture 8: Scheduling and Deadlock. Keith Marzullo

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)

8th Slide Set Operating Systems

Multiprocessor and Real-Time Scheduling. Chapter 10

CHAPTER 2: PROCESS MANAGEMENT

Chapter 6: CPU Scheduling

Practice Exercises 305

CS370: System Architecture & Software [Fall 2014] Dept. Of Computer Science, Colorado State University

CS370 Operating Systems

Opera&ng Systems ECE344

CPU THREAD PRIORITIZATION USING A DYNAMIC QUANTUM TIME ROUND-ROBIN ALGORITHM

FCM 710: Architecture of Secure Operating Systems

CSE 4/521 Introduction to Operating Systems

SIMULATION-BASED COMPARISON OF SCHEDULING TECHNIQUES IN MULTIPROGRAMMING OPERATING SYSTEMS ON SINGLE AND MULTI-CORE PROCESSORS *

Scheduling. CSC400 - Operating Systems. 7: Scheduling. J. Sumey. one of the main tasks of an OS. the scheduler / dispatcher

CS 153 Design of Operating Systems Winter 2016

LECTURE 3:CPU SCHEDULING

Transcription:

Session 3520 Introducing CPU Scheduling Algorithms: The Photocopier Scenario John K. Estell Bluffton College Retention is obtained from a combination of repetition and association. One methodology for promoting retention is to introduce a topic by first alluding to an association to which students can relate. This serves as a foundation upon which the technical material can then be based, making the learning of the involved concepts easier. Unfortunately, in the area of operating systems there is little time for repetition in the lecture and few materials are available that show associations. This paper is a first step in providing materials suitable for an operating systems course that illustrate concepts through associations. The subject of CPU (central processing unit) scheduling algorithms is not one that students can easily comprehend in the abstract. Normally students are presented in lecture with one algorithm after another, and as the concept of a process is often new and fuzzy the students have no intuitive grasp of the material. However, there are associations between a CPU and a photocopying machine that can be used to assist in the teaching of CPU scheduling algorithms. Both devices can be used by at most one entity at a time and there is often a queue awaiting access. Students can readily relate to waiting in line to use the photocopier, and because of this familiarity the associations can be presented in a short amount of time. By introducing the concepts behind the various types of scheduling algorithms using concrete examples in this context, students are given the framework that allows them to understand how the algorithms work. When the actual scheduling algorithms are then introduced using the traditional methodology, the concepts have already been explained, and the associations allow them to remember the technical material. The lectures on this topic begin with some background explanatory material. One of the fundamental actions of a multitasking operating system is the scheduling of resources. The CPU is one of the primary resources available on a computer system; the goal of CPU scheduling is to assign processes to be executed by the CPU over time in such a way that system objectives are met. There are a variety of schedulers that affect the long-term, medium-term, and short-term performance; the focus of this paper is on the short-term CPU scheduling algorithms performed by the dispatcher. The success of CPU scheduling depends on the property that process execution consists of a cycle of CPU execution and I/O wait; when a process is in an I/O wait state, another process should be allowed to use the currently idle CPU to increase the utilization of the resource. Ideally, the allocation of the CPU will be performed so as to optimize one or more aspects of system behavior, such as minimal response time, minimal overhead, maximal resource utilization, or maximal throughput. Once the basic definitions are presented, the concepts behind some well-known CPU scheduling algorithms can now be introduced by stating the following problem: In a library we have several people and one photocopier. Each person has a variety of items to photocopy - some have one page, others a few pages out of several books, and there are also those who want Page 2.262.1

to copy an entire book. How do we allocate access to the photocopier? Before continuing on, it can be briefly shown to the class that the persons in the example correspond to the various types of processes encountered on a computer system. Each individual represents a process. There are short processes (copying one page) and long processes (copying entire book). There are CPUbound processes that will perform many computations without interruption (copying a sequence of pages from one book) and there are I/O-bound processes that can perform only a few computations before an interruption occurs (copying a few pages each from several books, or single pages scattered throughout a single book). The CPU scheduling algorithms are presented by their actual name, but are explained only in terms of the photocopier scenario. To further illustrate the concepts, clip art graphics are used to visually show what is being discussed for each algorithm. The basic illustration, which is what students are most familiar with, is shown in Figure 1: a line of individuals waiting to use the photocopier. Figure 1. Representation of First Come First Served scheduling algorithm. This represents the FCFS (first come, first served) scheduling algorithm, where whoever arrives at the photocopier first gets to use it to make as many copies as desired. A distinction is made between the person using the photocopier, which corresponds to the active CPU process, and the people waiting in line to use the photocopier, which corresponds to the ready queue containing processes that are ready to use the CPU once access is obtained. The class discussion attempts to get the students involved by relating occurrences of having just a couple of pages to copy but having to wait a long time because the person using the photocopier was copying tens or hundreds of pages. This is something that almost every student has experienced. The class readily comes to the conclusion that while this is a simple mechanism for organizing photocopier use it results in a lot of unhappy people waiting for service, which is an unproductive use of their time. This sets the stage for discussing ways to prevent someone from being a resource hog by monopolizing the use of the photocopier. n copies! Mr. O. Verhead Figure 2. Representation of Round Robin scheduling algorithm. Page 2.262.2

The simplest method of allowing fair access to resources is the Round Robin algorithm. Illustrated in Figure 2, a person is allowed to use the photocopier once the head of the line is reached. However, there is now a copier monitor named O. Verhead (to indicate that the monitoring process introduces overhead into the computer system) that will allow the person using the photocopier to make at most a pre-determined number of copies. Once that limit is reached, the person is required by the monitor, who has been carefully counting the number of pages copied, to go back to the end of the line. In technical terms, the monitor preempted the user, thereby interrupting the current process. This requires the user to somehow bookmark the next page to be copied from the book so that the photocopying process can resume where it left off. One of the key things to discuss is to what the value of n - the maximum number of pages that can be copied before being preempted - should be set. If n is too small then the people in line waste a lot of time thrashing about in getting their materials set up for copying then having to put things away after just a few copies. If many pages need to be copied then this can result in spending a significant amount of time in preparing to use the photocopier, which takes away from actual photocopier use. If n is too large then the system degrades back to the FCFS algorithm and people in line will be forced to wait while someone is able to copy an entire book ahead of them. The class now discusses ways to handle this problem, which allows the instructor to introduce other scheduling methods. 5 7 3 9 427 4 19 3 - you re next! Figure 3. Representation of Shortest Job First scheduling algorithm. With the Shortest Job First algorithm shown in Figure 3, the monitor checks the line each time the photocopier is available for use and asks each person how many pages he or she needs to copy. The monitor then selects the person specifying the fewest number of pages to be the next user of the photocopier. This method has the benefit of allowing persons who require just a few copies ready access to the photocopier. However, there are also problems. It is possible that someone might undercount the number of pages to be copied and unfairly be placed in front of other users. If a person has a large number of copies to make, that individual might never gain access to the photocopier if people with fewer pages to copy continue to enter the line. Once a person with a large number of copies gains access to the photocopier the machine is tied up until all of the copies are made; in the meantime, a line of increasingly annoyed users can form behind the person at the photocopier. This particular problem is addressed by the Shortest Remaining Time (SRT) algorithm, illustrated in Figure 4. Page 2.262.3

5 7 8 9 427 61 4 2 - CUT IN NOW! 2 Figure 4. Representation of Shortest Remaining Time scheduling algorithm. In the SRT algorithm the line is check by the monitor whenever a person joins the line. If that person has fewer pages to copy than the current user of the photocopier, then the current user is preempted and the new person is given access to the photocopier. While this successfully addresses the problem of several users being stuck behind someone doing a large copying job, the role of the monitor is now increased, thereby adding to the overhead. Additionally, it is still possible that some users will encounter what is known as starvation, which is when one is denied access to the resource because of continuously receiving low priority evaluations from the monitor. After some more class discussion, ways to guarantee that large copying jobs eventually receive photocopier access is presented. 5 7 3 9 I ve been waiting OK - you re next! Figure 5. Representation of Highest Response Ratio Next scheduling algorithm. The Highest Response Ratio Next (HRRN) algorithm shown in Figure 5 requires the monitor to keep track of both the length of wait w and the time needed to make copies s for each person in line. When the photocopier becomes available, the response ratio (w + s)/s is calculated for every user. The user with the highest response ratio is selected by the monitor to use the photocopier. While this method favors short copying jobs, by taking into account the waiting time the longer copying jobs will eventually receive access. Page 2.262.4

L=1??? L*n copies maximum L=2??? L=4???? Figure 6. Representation of Multilevel Feedback scheduling algorithm. The multilevel feedback algorithm shown in Figure 6 establishes priority based on the number of photocopies already made instead of an estimated total number of copies. This is done by creating a number of lines, each with their own priority level. When a person wants to use the photocopier, he or she is placed by the monitor into the highest priority line. The individuals in the line access the photocopier using the FCFS algorithm, but when they receive access to the photocopier a limit is placed on the number of copies that can be made at that time. When users are preempted the monitor directs them to enter the next lower priority line. Users in the lower priority lines can access the photocopier only when all of the higher priority lines are empty; however, once access is obtained they are able to make more photocopies in this session than they were in previous sessions. The L values in the diagram indicate the relative maximum number of copies allowed for a person in line to make when at the photocopier; the L values are set so as to prevent starvation. One of the benefits of this approach is that it simplifies the role of the monitor. There is no need to know how many copies each user wants to make; the line that a person comes from to use the photocopier will determine the number of copies that can be made. This reduces the role of the monitor to keeping track of the lines, starting with the one with highest priority, and allowing the first person found to have access to the photocopier. I know you! Go to the short line! LONG MEDIUM SHORT Figure 7. Representation of Fair-Share scheduling algorithm. Page 2.262.5

The Fair-Share algorithm shown in Figure 7 keeps a history of recent photocopier use by each user. The monitor grants priority to those individuals who historically make the fewest copies while other users are placed into lines that reflect their photocopier usage. In this example the users are separated into having short, medium, or long photocopying jobs. The lines are treated in a similar manner as that used in the multilevel feedback algorithm, with the exception that if a user is preempted by the monitor or makes fewer copies than expected, then the next time the person comes to use the photocopier the monitor can reassign the individual to a different line. Now that the various scheduling algorithms have been introduced to the students, they can be revisited and explained using operating systems terminology. The associations that the students have been presented give them something to which to relate. This enables them to better understand what is transpiring with the dispatcher when it is attempting to select the next process to use the CPU and what the general benefits and drawbacks are for each algorithm. This method has been successfully used in our operating systems course. JOHN K. ESTELL joined Bluffton College as an associate professor of computer science in 1996. He was previously an associate professor in the EECS Department at The University of Toledo. He received a BS (1984) degree in computer science and engineering from Toledo and received both his MS (1987) and PhD (1991) degrees in computer science from the University of Illinois. His areas of interest include program development tools, robotics and interface design. Dr. Estell is a member of ACM, ASEE, IEEE, Tau Beta Pi, and Eta Kappa Nu. Page 2.262.6