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

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

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

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

Operating Systems. Scheduling

CSE 120 Principles of Operating Systems

Scheduling. The Basics

Last Class: Deadlocks. Today

OPERATING SYSTEMS CS3502 Spring Processor Scheduling. Chapter 5

CS 153 Design of Operating Systems Winter 2016

UNIT:2. Process Management

1.1 CPU I/O Burst Cycle

Properties of Processes

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

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

Chapter 5: CPU Scheduling

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

CPU Scheduling Algorithms

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

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

8: Scheduling. Scheduling. Mark Handley

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

CSE 120 Principles of Operating Systems Spring 2017

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

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

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

Chapter 6: CPU Scheduling

Last Class: Synchronization Problems. Need to hold multiple resources to perform task. CS377: Operating Systems. Real-world Examples

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

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

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

MC7204 OPERATING SYSTEMS

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

CSE 153 Design of Operating Systems

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

CPSC/ECE 3220 Summer 2018 Exam 2 No Electronics.

Homework Assignment #5

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

(b) External fragmentation can happen in a virtual memory paging system.

CPSC/ECE 3220 Summer 2017 Exam 2

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

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

FCM 710: Architecture of Secure Operating Systems

CMPS 111 Spring 2003 Midterm Exam May 8, Name: ID:

Operating System Concepts Ch. 5: Scheduling

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

Unit 3 : Process Management

Operating Systems ECE344. Ding Yuan

Scheduling of processes

Ch 4 : CPU scheduling

FCM 710: Architecture of Secure Operating Systems

CSL373: Lecture 6 CPU Scheduling

OPERATING SYSTEMS. Prescribed Text Book. Operating System Principles, Seventh Edition. Abraham Silberschatz, Peter Baer Galvin and Greg Gagne

COMP 3361: Operating Systems 1 Final Exam Winter 2009

Scheduling in the Supermarket

The Deadlock Problem (1)

CSE 4/521 Introduction to Operating Systems

Operating System Study Notes Department of Computer science and Engineering Prepared by TKG, SM and MS

Last Class: Processes

CHAPTER NO - 1 : Introduction:

Operating Systems (1DT020 & 1TT802)

CS3733: Operating Systems

Chapter 5: CPU Scheduling

Course Syllabus. Operating Systems

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

CMPS 111 Spring 2013 Prof. Scott A. Brandt Midterm Examination May 6, Name: ID:

Midterm Exam. October 20th, Thursday NSC

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

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

Chapter 3. Deadlocks

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

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

CS 318 Principles of Operating Systems

COP 4610: Introduction to Operating Systems (Spring 2016) Chapter 7 Deadlocks. Zhi Wang Florida State University

UNIT-3 DEADLOCKS DEADLOCKS

PROCESSES & THREADS. Charles Abzug, Ph.D. Department of Computer Science James Madison University Harrisonburg, VA Charles Abzug

Processes-Process Concept:

Techno India Batanagar Department of Computer Science & Engineering. Model Questions. Multiple Choice Questions:

QUESTION BANK UNIT I

Lecture 9: Midterm Review

Midterm Exam Amy Murphy 6 March 2002

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

Practice Exercises 305

Interactive Scheduling

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

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

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

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

The Deadlock Problem. A set of blocked processes each holding a resource and waiting to acquire a resource held by another process in the set.

Resources. Lecture 4. Deadlocks. Resources (2) Resources (1) Four Conditions for Deadlock. Introduction to Deadlocks

Readings and References. Deadlock. Deadlock. Simple Traffic Gridlock Example. Reading. CSE Computer Systems November 30, 2001.

CS370 Operating Systems

Process Scheduling. Copyright : University of Illinois CS 241 Staff

Operating Systems (Classroom Practice Booklet Solutions)

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

Delhi Noida Bhopal Hyderabad Jaipur Lucknow Indore Pune Bhubaneswar Kolkata Patna Web: Ph:

Problems Kernel Scheduler User Level Scheduler Universität Karlsruhe (TU), System Architecture Group

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

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)

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

Midterm Exam #2 Solutions October 25, 2016 CS162 Operating Systems

Transcription:

Operating Systems: Quiz2 December 15, 2006 Class: No. Name: Part I (30%) Multiple Choice Each of the following questions has only one correct answer. Fill the correct one in the blank in front of each question. 1. c The short-term scheduler is responsible for: a) selecting the shortest jobs to enter the system b) discarding job groups that should be removed from the system c) selecting which process should be allocated the CPU next d) swapping jobs out of memory e) None of the above. 2. b The average wait time for five processes P1-P5 with burst of 5, 19, 2, 16 and 7 milleseconds respectively, using SJF is : a) 5 milliseconds b) 10.6 milliseconds c) 28.25 milliseconds d) 9.8 milliseconds e) None of the above. 3. b The average wait time for four processes P1-P4 with bursts of 10, 4, 4, 6 milliseconds respectively, using shortest remaining time first (SRTF) with P1 arriving at time 0, and each subsequent process arriving every 2 milliseconds, is : a) 5 milliseconds b) 4 milliseconds c) 4.8 milliseconds d) 4.5 milliseconds e) 5.25 milliseconds 4. d What policy is provably optimal with respect to shortest average wait time? a) shortest job first b) first come first serve c) round robin d) shortest remaining time first e) None of the above. 5. c Which of the following is NOT part of the operating system? a) dispatcher b) memory manager c) text editor d) scheduler e) I/O driver. 6. a Suppose that the operating system is running a non-preemptive scheduler and that process p is currently running. A context switch can occur: a) When p terminates or blocks. b) When another process unblocks. c) When another process enters. d) When the time quantum is exhausted. e) When the priority of some other process exceeds the priority of p. 7. e A MLF scheduler uses 4 queues, the first 3 of which are serviced in round-robin fashion and the last is FCFS. Time quantums for the first 3 queues are 4 ms, 8 ms, and 16 ms respectively. What is the time quantum for the last queue? a) 2 ms b) 4 ms c) 16 ms d) 32 ms e) none of the above 8. a How does an SJF scheduler behave when jobs all require the same amount of CPU time? a) like the FCFS algorithm b) like the RR algorithm c) like the SRT algorithm d) like another priority algorithm e) none of the above 9. c Assume that a deadlock occurs in a computer. Which of the following statement is incorrect? a) All the deadlocked processes are blocked. b) Some resources are wasted forever unless the deadlock is resolved. c) All processes in the computer cannot complete their jobs. d) Each of the deadlocked processes is requesting some resources. e) none of the above. 10. b In a system where round robin is used for CPU scheduling, which of the following is true when a process cannot finish its computation during its current time quantum? a) The process s state will be changed from running to blocked. b) The process s state will be changed from running to ready. c) The process will be terminated by the operating system. d) The process will terminate itself. e) None of the above. 11. d A situation that occurs when a higher priority thread attempts to acquire a shared resource that is currently owned by a lower priority thread. (a) deadlock through starvation (b) deadlock through cyclic waiting (c) strict alternation (d) priority inversion (e) none of the above. 12. d Starvation is not a problem in: a) SJF scheduler. b) Multilevel-Priority scheduler. c) Multilevel Feedback scheduler with three queue levels, as long as the time slice of the highest level is less then the time slices of the lower levels. d) Round Robin with single priority level. (e) none of the above. 13. a A process was observed to switch from running to ready state. The scheduling must be: a) preemptive b) non-preemptive c) Round Robin d) Shortest Job First e) none of the above. 14. c A condition in which the behavior of two or more processes depends on the relative rate at which each process executes its instructions. a) deadlock b) indefinite postponement c) race condition d) strict alternation e) memory interlock 15. d The Banker s algorithm is for: a) process scheduling b) deadlock detection c) deadlock recovery d) deadlock avoidance e) deadlock prevention. 1

Part II (15%) True or False For each of the following questions, you get 1 point for a correct answer, 0.5 point for a wrong answer, and 0 point for blank. 1. F The main strength of a multi-level queue scheduler is to improve system/cpu throughput. 2. F Deadlocks can always be detected by finding a cycle in a resource allocation graph. 3. T Shortest-job-first scheduling is not suitable for a general-purpose computer system. 4. T A priority scheduler can cause starvation. 5. T All interactive systems use preemptive policies even though these policies have a higher overhead. 6. F Priority inversion is a condition that occurs in real-time systems where a lower priority process is starved because higher priority processes have gained hold of the CPU. 7. T An effective way to prevent deadlock is for the OS to require every process to request all of the resources (locks, files, etc.) when it begins to execute, and then release them all when it completes. 8. T The shortest-job-first scheduling algorithm can cause starvation. 9. T A non-preemptive process scheduler allows a process to run until its next I/O operation, or until it terminates. 10. F First-come-first-served scheduling is adequate for a time-sharing system. 11. F Round-robin scheduling is an example of priority scheduling. 12. F When an executing process is stopped by scheduler, it is said to be blocked. 13. F A process waiting for a semaphore, upon being signaled, immediately gets the CPU. 14. T If all the processes in a system need at most one non-sharable resource, then the system is free from deadlock. 15. F Avoiding to request resources that are needed immediately is one of strategy for deadlock avoidance. Part III (55%) Question Answering 1. What is priority inversion? Describe how it can be caused by locks and a negative effect that could result. (4%) Ans) Priority inversion is when a high priority thread is unnecessarily blocked by a lower priority thread. Locks can cause priority inversion in the following manner given 3 threads of low, medium, and high priority. The high-priority thread could block on a lock held by the low-priority thread. If the medium-priority thread wants the CPU, it will run instead of the low-priority thread unlike the low-priority thread (until it releases the lock), the medium-priority thread s execution should not block the progress of the high-priority thread. One possible result of such priority inversion is failure to meet a high-priority deadline in a real-time system. 2. What is the difference between a race condition and deadlock? (3%) Ans) A race condition is caused by more than one thread accessing shared state without synchronization. Threads continue to execute, but the program can have incorrect results. In a deadlock, threads cannot make any progress. They are all waiting to acquire resources that each other holds (circular wait) while the three other deadlock conditions hold. 3. Give the four necessary conditions for deadlock to occur. (4%) Ans) (a) Mutual exclusion no two processes can share resource (b) Hold and wait process holding can request additional resources (c) No preemption processes cant be kicked out of resource (d) Circular wait must be cycle in resource graph 2

4. Distinguish between deadlock avoidance and deadlock prevention. (4%) Ans) Deadlock avoidance seeks to prevent entry into any usafe state that is, one where there is a possible sequence of events leading to deadlock. Avoidance is a conservative approach; example is Banker s algorithm. Deadlock prevention tries to eliminate deadlock more precisely, by removing one of the necessary conditions for deadlock. 5. The table below lists five jobs, the time that they arrive in the system (when they are created), how long they take to execute, and their priority (higher values correspond to higher priorities). For example, job A arrives at time 10, requires 30 units of execution time to complete, and has priority 1. Job Arrival Time Execution Time Priority A 10 30 1 B 20 50 5 C 30 10 3 D 40 40 2 E 50 20 0 For all jobs in each of the following scheduling algorithms, calculate (a) the Start Time, the time at which the job is first scheduled to run (it may have to wait when it arrives), and (b) the End Time, the time when it finishes executing. (20%) FCFS SJF SRT Priority Job Start End Start End Start End Start End Time Time Time Time Time Time Time Time A 10 40 10 50 10 40 10 140 B 40 90 110 160 110 160 20 70 C 90 100 30 40 40 50 70 80 D 100 140 70 110 70 110 80 120 E 140 160 50 70 50 70 140 160 6. Deadlock: Consider a system that starts with a total of 150 units of memory, which is then allocated to three processes as shown in the following table of processes, their maximum resource requirements, and their current allocations: Process Max Demand Currently holds p 1 70 45 p 2 60 40 p 3 60 15 p 4 50 Determine whether it would be safe to grant each of the following requests. If YES, give an execution order that could be guaranteed possible. If NO, say the reason. (a) A fourth process arrives, with a maximum memory need of 50 and an initial request for 25 units. (4%) Ans) YES, safe. 25 units will be left after the allocation for p 4, so there is sufficient memory to guarantee the termination of either p 1 or p 2. After that, the remaining three jobs can be completed in any order. (b) Using the original table above, a fourth process arrives, with a maximum memory need of 50 and an initial request for 35 units. (4%) Ans) NO, unsafe. 15 units will be left after the allocation for p 4, so there is insufficient memory to guarantee the termination of any process. 7. Consider the following information about resources in a system: There are two classes of allocatable resource labelled R 1 and R 2. There are two instances of each resource. There are four processes labelled p 1 through p 4. There are some resource instances already allocated to processes, as follows: 3

one instance of R 1 held by p 2, another held by p 3 one instance of R 2 held by p 1, another held by p 4 Some processes have requested additional resources, as follows: p 1 wants one instance of R 1 p 3 wants one instance of R 2 (a) Draw the resource allocation graph for this system. (4%) Ans) (b) What is the state (runnable, waiting) of each process? For each process that is waiting, indicate what it is waiting for. (4%) Ans) p 1 is waiting for R 1, p 2 is runnable, p 3 is waiting for R 2 and p 4 is runnable. (c) Is this system deadlocked? If so, state which processes are involved. If not, give an execution sequence that eventually ends, showing resource acquisition and release at each step. (4%) Ans) Not deadlocked One possible execution sequence: p 2, p 4, p 1,p 3, such as 4

5