Homework Assignment #5

Similar documents
CPU Scheduling Algorithms

Properties of Processes

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

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

SAMPLE MIDTERM QUESTIONS

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

EECE.4810/EECE.5730: Operating Systems Spring 2017 Homework 3 Solution

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

Chapter 6: CPU Scheduling

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

1.1 CPU I/O Burst Cycle

CS450 OPERATING SYSTEMS FINAL EXAM ANSWER KEY

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

King Saud University. College of Computer & Information Sciences. Information Technology Department. IT425: Operating Systems.

COMP 300E Operating Systems Fall Semester 2011 Midterm Examination SAMPLE. Name: Student ID:

UNIT:2. Process Management

Maximum CPU utilization obtained with multiprogramming. CPU I/O Burst Cycle Process execution consists of a cycle of CPU execution and I/O wait

General Objectives: To understand the process management in operating system. Specific Objectives: At the end of the unit you should be able to:

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

Midterm Exam. October 20th, Thursday NSC

Unit 3 : Process Management

CPU Scheduling: Part I ( 5, SGG) Operating Systems. Autumn CS4023

Operating Systems Comprehensive Exam. Spring Student ID # 2/17/2011

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

Operating Systems (Classroom Practice Booklet Solutions)

CMPT 300: Operating Systems I Assignment 1

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

CS370 Operating Systems

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

Operating Systems Comprehensive Exam. Spring Student ID # 3/16/2006

Operating System Concepts Ch. 5: Scheduling

COMP SCI 3SH3: Operating System Concepts (Term 2 Winter 2006) Test 2 February 27, 2006; Time: 50 Minutes ;. Questions Instructor: Dr.

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

Department of Computer applications. [Part I: Medium Answer Type Questions]

Starting the Threads

Chapter 5: Process Synchronization. Operating System Concepts 9 th Edition

STUDENT NAME: STUDENT ID: Problem 1 Problem 2 Problem 3 Problem 4 Problem 5 Total

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

CSSE 340 Operating Systems Project 2: CPU Scheduling Simulator

QUESTION BANK. UNIT II: PROCESS SCHEDULING AND SYNCHRONIZATION PART A (2 Marks)

Operating Systems. Scheduling

( D ) 4. Which is not able to solve the race condition? (A) Test and Set Lock (B) Semaphore (C) Monitor (D) Shared memory

So far. Next: scheduling next process from Wait to Run. 1/31/08 CSE 30341: Operating Systems Principles

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

OPERATING SYSTEMS CS3502 Spring Processor Scheduling. Chapter 5

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

CHAPTER 2: PROCESS MANAGEMENT

CS630 Operating System Design, First Exam, Spring 2017,

CS370 Operating Systems Midterm Review. Yashwant K Malaiya Spring 2019

Chapter 5: CPU Scheduling

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

CSE 120 Principles of Operating Systems Spring 2017

Lecture 2 Process Management

CS3733: Operating Systems

Programming Assignment HW4: CPU Scheduling v03/17/19 6 PM Deadline March 28th, 2019, 8 PM. Late deadline with penalty March 29th, 2019, 8 PM

CS Mid term Exam Maximum points 100; Maximum time allowed: 75 minutes

Programming Assignment HW5: CPU Scheduling draft v04/02/18 4 PM Deadline April 7th, 2018, 5 PM. Late deadline with penalty April 9th, 2018, 5 PM

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

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

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

CSE 4/521 Introduction to Operating Systems

OS 1 st Exam Name Solution St # (Q1) (19 points) True/False. Circle the appropriate choice (there are no trick questions).

Operating Systems (1DT020 & 1TT802)

EECE.4810/EECE.5730: Operating Systems Spring 2017

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

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

Remaining Contemplation Questions

TDDD82 Secure Mobile Systems Lecture 6: Quality of Service

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

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

Scheduling of processes

FCM 710: Architecture of Secure Operating Systems

OS Assignment II. The process of executing multiple threads simultaneously is known as multithreading.

CS604 - Operating System Solved Subjective Midterm Papers For Midterm Exam Preparation

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

CSE 120 Principles of Operating Systems

Practice Exercises 305

Scheduling. The Basics

Chapter 6: CPU Scheduling

1. Motivation (Race Condition)

UNIT II PROCESS SCHEDULING AND SYNCHRONIZATION

Last Class: Processes

Operating Systems Comprehensive Exam. Spring Student ID # 3/20/2013

Job Scheduling. CS170 Fall 2018

COMP 3361: Operating Systems 1 Final Exam Winter 2009

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

( B ) 4. Which is not able to solve the race condition? (A) Test and Set Lock (B) Shared memory (C) Semaphore (D) Monitor

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

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

Course Syllabus. Operating Systems

Operating Systems Comprehensive Exam. Fall Student ID # 10/31/2013

Chapter 2 Processes and Threads. Interprocess Communication Race Conditions

Chapter 5 CPU scheduling

Advanced Operating Systems (CS 202) Scheduling (1)

EECE.4810/EECE.5730: Operating Systems Spring Midterm Exam March 8, Name: Section: EECE.4810 (undergraduate) EECE.

CPSC/ECE 3220 Summer 2018 Exam 2 No Electronics.

Operating Systems ECE344. Ding Yuan

8: Scheduling. Scheduling. Mark Handley

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

Operating System Review Part

Transcription:

Homework Assignment #5 Question 1: Scheduling a) Which of the following scheduling algorithms could result in starvation? For those algorithms that could result in starvation, describe a situation in which starvation is likely to occur? 1. First-Come First-Served (FCFS) 2. Shortest Job First (SJF) (Non-preemptive) 3. Shortest Remaining Time First (SRTF) (Preemptive) 4. Round Robin (RR) 5. Priority b) Consider the set of process (smaller priority number implies higher priority; i.e. 1 highest priority): Process ID Arrival Time Burst Time Priority P1 0 70 3 P2 10 50 2 P3 30 20 1 P4 50 20 4 Draw the GANTT chart for the following scheduling algorithms. First-Come First-Served (FCFS) Shortest Job First (SJF) (Non-preemptive) Shortest Remaining Time First (SRTF) (Preemptive) Round Robin (RR) (Time Quantum = 10, Round from P1 to PN if PN arrives) Priority (Non-preemptive)

c) For the processes listed above, complete the following table: Scheduling Algorithm First Come First Served (FCFS) Shortest Job First (SJF) (Nonpreemptive) Shortest Job First (SJF) (preemptive) Round Robin (RR) (Time Quantum = 10) Priority (Non-preemptive) Average waiting time Average turnaround time d). Briefly reason why the average waiting time of preemptive SJF is guaranteed to be no larger than that of non-preemptive. (No need to prove) e). Consider a set of 10 processes with identical burst times and similar arrival times scheduled using a round robin algorithm. Let the overhead of context switch be 2 milliseconds. To reduce the relative context switch overhead, we wish to bound the total time for context switch to be one-fifth of the total waiting time. Develop an equation to calculate the minimum value of quantum q for this condition to be satisfied (Hints: Think carefully about the components of waiting time).

Question 2: Test-and-set, Critical Section Consider the following code segment covered in the lecture: var j: 0 n-1 key:boolean, lock:= false; 0: repeat { 1: waiting[i] = true; key:=true; 2: while (waiting[i] and key) do key:=test-and- Set(lock); 3: waiting[i]:=false; 4: critical section 5: j:=j + 1 mod n 6: while ((j<>i) and (not waiting[j])) do j : = j + 1 mod n; 7: if j = i then lock:=false; 8: else waiting[j] = false; 9: remain section 10: } until false (a).the above program that we saw in the lecture can achieve both bounded waiting and mutual exclusion with test-and-set. Assume line 3 of this code above is deleted. Determine if the algorithm still works as desired after that line is deleted.

Consider the following algorithm that provides a solution to the 2 process critical section problem. flag[0] = false; flag[1] = false; P0: 0: while (true) { 1: flag[0] = true; 2: while (flag[1]) { 3: flag[0] = false; 4: while (flag[1]) { 5: no-op; 6: } 7: flag[0] = true; 8: } 9: critical section 10: flag[0] = false; 11: remainder section 12: } P1: 0: while (true) { 1: flag[1] = true; 2: while (flag[0]) { 3: flag[1] = false; 4: while (flag[0]) { 5: no-op; 6: } 7: flag[1] = true; 8: } 9: critical section 10: flag[1] = false; 11: remainder section 12: } b). Specify which of the following requirements are satisfied or not by this algorithm. Explain why or why not. 1. Mutual Exclusion 2. Progress 3. Bounded Waiting

Question 3: Semaphores In an operating system processes can run concurrently. Sometimes we need to impose a specific order in execution of a set of processes. We represent the execution order for a set of processes using a process execution diagram. Consider the following process execution diagram. The diagram indicates that Pr1 must terminate before Pr2, Pr3 and Pr4 start execution. It also indicates that Pr4 should start after Pr2 and Pr3 terminate and Pr2 and Pr3 can run concurrently. We can use semaphores in order to enforce the execution order. Semaphores have two operations as explained below. P (or wait) is used to acquire a resource. It waits for semaphore to become positive, then decrements it by 1. V (or signal) is used to release a resource It increments the semaphore by 1, waking up the blocked processes, if any. We can use the following semaphores to enforce the execution order. s1=0; s2=0; s3=0; Pr1: body; V(s1); V(s1); Pr2: P(s1); body; V(s2); Pr3: P(s1); body; V(s3); Pr4: P(s2); P(s3); body; Assume that the semaphores s1, s2, and s3 are created with an initial value of 0 before processes Pr1, Pr2, Pr3, and Pr4 execute.

Based on this explanation, answer the questions about the following process execution graph. a) Use semaphores to enforce execution order according to the process execution diagram.