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



Similar documents
Operating System: Scheduling

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

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

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

ICS Principles of Operating Systems

Job Scheduling Model

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

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

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

CPU Scheduling. CPU Scheduling

Concepts of Concurrent Computation

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

Real-Time Scheduling 1 / 39

CPU Scheduling Outline

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

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

OPERATING SYSTEMS SCHEDULING

Operating Systems Lecture #6: Process Management

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

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

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

Operating Systems. III. Scheduling.

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

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

CPU SCHEDULING (CONT D) NESTED SCHEDULING FUNCTIONS

W4118 Operating Systems. Instructor: Junfeng Yang

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

Scheduling Algorithms

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

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

Multiprocessor Scheduling and Scheduling in Linux Kernel 2.6

CPU Scheduling. Core Definitions

OS OBJECTIVE QUESTIONS

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

Threads Scheduling on Linux Operating Systems

Operating Systems Concepts: Chapter 7: Scheduling Strategies

Introduction. Scheduling. Types of scheduling. The basics

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

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

Synchronization. Todd C. Mowry CS 740 November 24, Topics. Locks Barriers

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

Analysis and Comparison of CPU Scheduling Algorithms

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

Chapter 5 Process Scheduling

Operating Systems, 6 th ed. Test Bank Chapter 7

CS414 SP 2007 Assignment 1

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

A Comparative Study of CPU Scheduling Algorithms

PROCESS SCHEDULING ALGORITHMS: A REVIEW

Operating System Tutorial

Tasks Schedule Analysis in RTAI/Linux-GPL

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

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

General Overview of Shared-Memory Multiprocessor Systems

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

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

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

Syllabus MCA-404 Operating System - II

Contributions to Gang Scheduling

Operating Systems OBJECTIVES 7.1 DEFINITION. Chapter 7. Note:

First-class User Level Threads

Comparison between scheduling algorithms in RTLinux and VxWorks

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

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

Load Balancing Scheduling with Shortest Load First

Operating Systems 4 th Class

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

Multi-core Programming System Overview

Server Scheduling to Balance Priorities, Fairness and Average Quality of Service

Undergraduate Course Syllabus

Disks and RAID. Profs. Bracy and Van Renesse. based on slides by Prof. Sirer

Linux Process Scheduling Policy

CHAPTER 1 INTRODUCTION

Processes and Non-Preemptive Scheduling. Otto J. Anshus

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

Resource Reservation & Resource Servers. Problems to solve

218 Chapter 5 CPU Scheduling

Scheduling. Monday, November 22, 2004

Scheduler Activations: Effective Kernel Support for the User-Level Management of Parallelism

Overview Motivating Examples Interleaving Model Semantics of Correctness Testing, Debugging, and Verification

Far-western University Central Office, Mahendranagar Operating System

MASSACHUSETTS INSTITUTE OF TECHNOLOGY Computer Systems Engineering: Spring Quiz I Solutions

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

CS0206 OPERATING SYSTEMS Prerequisite CS0201, CS0203

A Review on Load Balancing In Cloud Computing 1

Chapter 7: Deadlocks!

Chapter 2: OS Overview

Gildart Haase School of Computer Sciences and Engineering

Midterm Exam #2 Solutions November 10, 1999 CS162 Operating Systems

Final Report. Cluster Scheduling. Submitted by: Priti Lohani

An Implementation Of Multiprocessor Linux

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

Introduction. What is an Operating System?

Database Management System Prof. D. Janakiram Department of Computer Science & Engineering Indian Institute of Technology, Madras Lecture No.

Why Threads Are A Bad Idea (for most purposes)

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

Linux Scheduler. Linux Scheduler

A Guide to Getting Started with Successful Load Testing

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

Transcription:

CS4410 - Fall 2008 Homework 2 Solution Due September 23, 11:59PM Q1. Explain what goes wrong in the following version of Dekker s Algorithm: CSEnter(int i) inside[i] = true; while(inside[j]) inside[i] = false; while(turn == j) continue; inside[i] = true; CSExit(int i) turn = j; inside[i] = false; There is a possibility of starvation here. Suppose process j is in critical section and process i is busy waiting at the inner while loop. Now when process j exits the critical section it sets turn = i, but it immediately tried to access the critical section and so sets inside[j] = true. Right before process j executes while (inside[i]), scheduler schedules process i. Now process i exits from the inner while loop as turn = = i now, but it finds inside[j] to be true so continue the outer while loop. Then after it executes inside[i]=false, the scheduler schedules process j and it finds the condition at outer while loop to be false and enters the critical section. As a result, process i busy waits at outer while loop. These steps can repeat arbitrary number of times and that starves process i and it may never enter the critical section. In the original algorithm, there is an extra checking if (turn==j) which ensures that this starvation never happens. -5 : Failing to mention starvation / violation of bounded waiting; mentioning it violates mutual exclusion (two threads inside the critical section simultaneously) which actually does not happen here. -1 : Mentioning starvation, but no explanation how it happens -5 : Just mentioning it does not have "if (turn==j)", but no explanation on why it is wrong (i.e., starvation/violation of bounded waiting)

Q2. Round-robin schedulers normally maintain a list of all runnable processes, with each process occurring exactly once in the list. What would happen if a process occurred twice in the list? Can you think of any reason for allowing this? If a processor occurs more than once in the round-robin list, then it will get two turns for each pass through the list. One reason for allowing this would be to implement a primitive priority system since the more times it occurs on the list, the higher the percentage of time the CPU will spend on that process. Almost all answers were correct. Some of you lose 3 points for failing to explain the why part. Q3. Five batch jobs A through E, arrive at a computer center at almost the same time. They have estimated running times of 11, 6, 2, 4, and 8 minutes. Their (externally determined) priorities are 3, 5, 2, 1, and 4, respectively, with 5 being the highest priority. For each of the following scheduling algorithms, determine the mean process turnaround time. Ignore process switching overhead. (a) Round-robin (b) Priority scheduling (c) First come, First served (run in order 11, 6, 2, 4, 8) (d) Shortest job first For (a), assume that the system is multiprogrammed, and that each job gets its fair share of the CPU. For (b) through (d) assume that only one job runs at a time, until it finishes. All jobs are completely CPU bound. Assume that the time quantum of the scheduler is 1 minute. Remember that the turnaround time is the amount of time that elapses between the job arriving and the job completing. Since we assume that all jobs arrive at time 0, the turnaround time will simply be the time that they complete. (a) Round Robin: The table below gives a break down of which jobs will be processed during each time quantum. A * indicates that the job completes during that quantum.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 A B C D E A B C* D E A B D E A 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 B D* E A B E A B* E A E A E* A A A* Average turnaround = (8 + 17 + 23 + 28 + 31)/5 = 107/5 = 21.4 minutes (b) Priority Scheduling: 1-6 7-14 15-25 26-27 28-31 B E A C D Avg. turnaround = (6 + 14 + 25 + 27 + 31)/5 = 103/5 = 20.6 minutes (c) FCFS 1-11 12-17 18-19 20-23 24-31 A B C D E Avg. turnaround = (11 + 17 + 19 + 23 + 31)/5 = 101/5 = 20.2 minutes (d) SJF 1-2 3-6 7-12 13-20 21-31 C D B E A Avg. turnaround = (2 + 6 + 12 + 20 + 31)/5 = 71/5 = 14.2 minutes Finding the average process turnaround time can also be done by multiplying the number of unfinished processes by the time they remain unfinished dividing by number of processes. This makes finding solutions for parts b, c, and d particularly efficient. For example, the calculation for part C can be represented by (5*11 + 4*6 + 3*2 + 2*4 + 1*8)/5. Grading guide Each part of the four parts of question 3 were worth a total of 2.5 points. More than 2.5 points could not be lost for any part. They were graded as follows: -1 Intermediate mistake in work such as incorrect process turnaround time or diagram, but correct final answer. -2 Intermediate mistake in work, but correct final answer given that mistake. For example using process turnaround time of 15 minutes when it should be 25 minutes.

-1 Mistake in arithmetic. -1 Using wrong time quantum in part a. -1 Reversing priority in part b. -1.25 Calculating wait time instead of turnaround time. -2 Not using given values. For example making A take 12 minutes to complete instead of 11. (Points only taken off once for all of question 3) -1 Determining order of round-robin by priority. As described on page 194 [Silberschatz], Round-Robin scheduling is the same as first come first serve, except with preemption. The assumption is that the processes are delivered in A,B,C,D,E order, and if a different assumption is made then they should be round-robin scheduled in the same order as the FCFS method. -2.5 Incorrect final answer and incorrect or missing work. Q4. Can we use the test-and-set instruction to implement a lock on a multiprocessor environment? Explain why or why not. In the multiprocessor environment, the test-and-set instruction should still work. Because it operates atomically on a single memory location, even with multiple processors sharing the same memory, the test-and-set instruction will still operate as expected. -3 why part is wrong -5 answer wrong, but relevant analysis is somewhat ok Q5. Consider the environment where many user-level threads are mapped to a single kernel thread (i.e., the many-to-one model). Describe a situation the one-to-one model outperforms this model. The chief benefit of the one-to-one model over the many-to-one model is that it allows for more concurrency within a program. In the many-to-one model, if a thread makes a blocking system call, all the threads of that process have to wait to be scheduled again.

Clearly, any environment where threads make frequent system calls is one where the oneto-one model outperforms many-to-one. -5 answer wrong, but relevant analysis is somewhat ok