Midterm Exam March 7, 2001 CS162 Operating Systems

Similar documents
Midterm Exam Solutions March 7, 2001 CS162 Operating Systems

Spring 2001 Midterm Exam, Anthony D. Joseph

Midterm Exam March 13, 2013 CS162 Operating Systems

Midterm Exam March 3, 1999 CS162 Operating Systems

Midterm Exam #1 February 28, 2018 CS162 Operating Systems

Midterm Exam #1 September 29, 1999 CS162 Operating Systems

University of California College of Engineering Computer Science Division- EECS. Midterm Exam March 13, 2003 CS162 Operating Systems

Midterm Exam Solutions and Grading Guidelines March 3, 1999 CS162 Operating Systems

Student Name: University of California at Berkeley College of Engineering Department of Electrical Engineering and Computer Science

Second Midterm Exam March 21, 2017 CS162 Operating Systems

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

Midterm #2 Exam April 26, 2006 CS162 Operating Systems

Midterm I October 12 th, 2005 CS162: Operating Systems and Systems Programming

Midterm I October 18 th, 2010 CS162: Operating Systems and Systems Programming

Midterm Exam October 15, 2012 CS162 Operating Systems

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

Midterm I October 11 th, 2006 CS162: Operating Systems and Systems Programming

Midterm Exam #2 April 20, 2016 CS162 Operating Systems

Midterm Exam #1 Solutions February 28, 2018 CS162 Operating Systems

Midterm Exam #2 April 16, 2008 CS162 Operating Systems

Midterm Exam #2 December 4, 2013 CS162 Operating Systems

Midterm Exam #2 Solutions April 20, 2016 CS162 Operating Systems

Midterm #2 Exam Solutions April 26, 2006 CS162 Operating Systems

Midterm Exam #2 April 29, 2003 CS162 Operating Systems

First Midterm Exam September 28, 2017 CS162 Operating Systems

Midterm Exam #3 Solutions November 30, 2016 CS162 Operating Systems

First Midterm Exam Solutions October 1, 2018 CS162 Operating Systems

CS 162 Midterm Exam. October 18, This is a closed book examination. You have 60 minutes to answer as many questions

Midterm I February 28 th, 2019 CS162: Operating Systems and Systems Programming

Third Midterm Exam April 24, 2017 CS162 Operating Systems

Final Exam Solutions May 11, 2012 CS162 Operating Systems

Midterm I October 19 th, 2009 CS162: Operating Systems and Systems Programming

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

University of California at Berkeley College of Engineering Department of Electrical Engineering and Computer Science

CS450 OPERATING SYSTEMS FINAL EXAM ANSWER KEY

Problem Max Points Score Total 100

Midterm I October 15 th, 2008 CS162: Operating Systems and Systems Programming

CS 450 Exam 2 Mon. 11/7/2016

Midterm II December 4 th, 2006 CS162: Operating Systems and Systems Programming

CS162, Spring 2004 Discussion #6 Amir Kamil UC Berkeley 2/26/04

CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring Lecture 8: Semaphores, Monitors, & Condition Variables

Third Midterm Exam April 24, 2017 CS162 Operating Systems

Midterm Exam Amy Murphy 6 March 2002

Operating Systems (1DT020 & 1TT802)

Midterm Exam Amy Murphy 19 March 2003

Department of Electrical Engineering and Computer Sciences Spring 2001 Instructor: Dan Garcia CS 3 Midterm #2. Personal Information

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

Midterm Exam #1 September 28, 2016 CS162 Operating Systems

COMP 3361: Operating Systems 1 Midterm Winter 2009

Final Exam Solutions May 17, 2013 CS162 Operating Systems

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

CSE 120 Principles of Operating Systems

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

OPERATING SYSTEMS CS3502 Spring Processor Scheduling. Chapter 5

CMPSCI 377: Operating Systems Exam 1: Processes, Threads, CPU Scheduling and Synchronization. October 9, 2002

CPS 310 midterm exam #1, 2/19/2016

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

Read and fill in this page now. Your lab section day and time: Name of the person sitting to your left: Name of the person sitting to your right:

Name: NETID: issuing a write to an I/O device, e.g. the disk, keyboard or the network card

CS 3204 Operating Systems Programming Project #2 Job / CPU Scheduling Dr. Sallie Henry Spring 2001 Due on February 27, 2001.

KEY CENG 334. Midterm. Question 1. Question 2. Question 3. Question 4. Question 5. Question 6. Total. Name, SURNAME and ID

CPS 310 second midterm exam, 11/14/2014

IMPORTANT: Circle the last two letters of your class account:

CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring 2002

SAMPLE MIDTERM QUESTIONS

Computer Science 161

Subversion was not there a minute ago. Then I went through a couple of menus and eventually it showed up. Why is it there sometimes and sometimes not?

CSE 120 Principles of Operating Systems Spring 2017

CS4411 Intro. to Operating Systems Exam 2 Fall 2009

Deadlocks: Detection & Avoidance

Midterm Exam Solutions Amy Murphy 28 February 2001

Job Scheduling. CS170 Fall 2018

CPS 110 Final Exam. Spring 2011

Thread Synchronization: Foundations. Properties. Safety properties. Edsger s perspective. Nothing bad happens

Technical Arts 101 Prof. Anupam Saxena Department of Mechanical engineering Indian Institute of Technology, Kanpur. Lecture - 7 Think and Analyze


University of Waterloo Midterm Examination Model Solution CS350 Operating Systems

CS125 : Introduction to Computer Science. Lecture Notes #11 Procedural Composition and Abstraction. c 2005, 2004 Jason Zych

First Midterm Exam September 28, 2017 CS162 Operating Systems

CODE MAROON TEST SEPT. 30, 2011 SURVEY RESULTS

Advanced Operating Systems (CS 202) Scheduling (1)

CPS 110 Midterm. Spring 2011

COMP 3361: Operating Systems 1 Final Exam Winter 2009

(Refer Slide Time: 1:26)

Fundamentals of Operations Research. Prof. G. Srinivasan. Department of Management Studies. Indian Institute of Technology Madras.

FCM 710: Architecture of Secure Operating Systems

Suggested Solutions (Midterm Exam October 27, 2005)

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

Stanford University Computer Science Department CS 140 Midterm Exam Dawson Engler Winter 1999

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

Scheduling of processes

It s possible to get your inbox to zero and keep it there, even if you get hundreds of s a day.

CPSC/ECE 3220 Summer 2018 Exam 2 No Electronics.

CS-537: Midterm Exam (Fall 2013) Professor McFlub

Midterm II December 3 rd, 2007 CS162: Operating Systems and Systems Programming

5. Synchronization. Operating System Concepts with Java 8th Edition Silberschatz, Galvin and Gagn

time are in milliseconds. Compute the average turnaround time for the system taking pre-emptive shortest job first (SJF) algorithm.

Lecture 9: Midterm Review

University of Illinois at Chicago Department of Computer Science. Final Examination. CS 151 Mathematical Foundations of Computer Science Fall 2012

CS125 : Introduction to Computer Science. Lecture Notes #38 and #39 Quicksort. c 2005, 2003, 2002, 2000 Jason Zych

Transcription:

University of California, Berkeley College of Engineering Computer Science Division EECS Spring 2001 Anthony D. Joseph Midterm Exam March 7, 2001 CS162 Operating Systems Your Name: SID AND 162 Login: TA: Discussion Section: General Information: This is a closed book and notes examination. You have ninety minutes to answer as many questions as possible. The number in parentheses at the beginning of each question indicates the number of points given to the question; there are 100 points in all. You should read all of the questions before starting the exam, as some of the questions are substantially more time consuming. Write all of your answers directly on this paper. Make your answers as concise as possible. If there is something in a question that you believe is open to interpretation, then please ask us about it! Good Luck!! Problem Possible Score 1 12 2 24 3 23 4 18 5 23 Total 100 Page 1/11

1. (12 points total) Lightweight versus Heavyweight processes Pros and Cons: a. (4 points) List two advantages of running a group of applications as single-threaded heavyweight processes over running the applications as multiple lightweight processes, all in one address space. Be explicit in your answers. i) b. (8 points) List two reasons why lightweight processes are better than heavyweight ones. i) ii) 2. (24 points total) Suppose that we have a multiprogrammed computer in which each job has identical characteristics. In one computation period, T, for a job, half the time is spent in I/O and the other half in processor activity. Each job runs for a total of N periods. Assume that a simple round-robin scheduling scheme is used and that I/O operations can overlap with processor operation. We define the following quantities: Turnaround time = actual time to complete a job. Processor utilization = percentage of time that the processor is active (not waiting). For large N, compute approximate values for these quantities for one, two, and four simultaneous jobs, assuming that the period T is distributed in each of the following ways: a. (15 points) I/O first half, processor second half. i) 1 job, Turnaround time and Processor utilization: ii) 2 jobs, Turnaround time and Processor utilization: iii) 4 jobs, Turnaround time and Processor utilization: Page 2/11

b. (9 points) I/O first and fourth quarters, processor second and third quarters. i) 1 job, Turnaround time and Processor utilization: ii) 2 jobs, Turnaround time and Processor utilization: iii) 4 jobs, Turnaround time and Processor utilization: 3. (23 points total) CPU scheduling. a. (8 points) Given CPU-bound tasks and a choice between FIFO and Round-Robin scheduling algorithms, choose the best algorithm for each of the following systems and specify why you chose the algorithm: i) Multiprogrammed batch system: ii) Interactive, time-sharing system: Page 3/11

b. (15 points) Consider the following processes, arrival times, and CPU processing requirements: Process Name Arrival Time Processing Time 1 0 4 2 1 4 3 4 3 4 8 2 For each of the following scheduling algorithms, fill in the table with the process that is running on the CPU. Assume a 1 unit timeslice for timeslice-based algorithms. For RR, assume that an arriving thread runs at the beginning of its arrival time. Time FIFO RR SRTF 0 1 1 1 1 2 3 4 5 6 7 8 9 10 11 12 Average response time Page 4/11

4. (18 points total) Concurrency problem: Building H 2 O. The goal of this exercise is for you to create a monitor with methods Hydrogen() and Oxygen(), which wait until a water molecule can be formed and then return. Don t worry about actually creating the water molecule; instead only need to wait until two hydrogen threads and one oxygen thread can be grouped together. For example, if two threads call Hydrogen, and then a third thread calls Oxygen, the third thread should wake up the first two threads and they should then all return. a. (6 points) Specify the correctness constraints. Be succinct and explicit in your answer. Page 5/11

b. (12 points) Observe that there is only one condition any thread will wait for (i.e., a water molecule being formed). However, it will be necessary to signal hydrogen and oxygen threads independently, so we choose to use two condition variables, waitingh and waitingo. Define wh and wo to be the number of hydrogen and oxygen threads waiting in the monitor, respectively, and we define ah an ao as the number of assigned hydrogen and oxygen threads, respectively. These are all initialized to 0. You start with the following code: Hydrogen() { wh++; lock.acquire(); while (ah == 0) { if (wh >= 2 && wo >= 1) { wh-=2; ah+=2; wo-=1; ao+=1; waitingh.broadcast(); waitingo.signal(); else { lock.release(); waitingh.wait(); lock.acquire(); lock.release(); ah--; Oxygen() { wo++; while (ao == 0) { if (wh >= 2 && wo >= 1) { wh-=2; ah+=2; wo-=1; ao+=1; waitingh.signal(); waitingh.signal(); else { waitingo.broadcast(); ao--; For each method, say whether the implementation either (i) works, (ii) doesn t work, or (iii) is dangerous that is, sometimes works and sometimes doesn t. If the implementation does not work or is dangerous, explain why (there maybe several errors) and show how to fix it so it does work. Also, list and fix any inefficiencies. i. Hydrogen() Page 6/11

ii. Oxygen() Page 7/11

(Additional space for question 4) Page 8/11

No Credit Problem X: (000000000000 points) Late Night Fun in the Labs (don t try this tonight) From a student in CS ###: For a computer programming class, I sat directly across from someone, and our computers were facing away from each other. A few minutes into the class, he got up to leave the room. I reached between our computers and switched the inputs for the keyboards. He came back and started typing and immediately got a distressed look on his face. He called the Lab TA over and explained that no matter what he typed, nothing would happen. The TA tried everything. By this time I was hiding behind my monitor and quaking red-faced. I started to type, Leave me alone! They both jumped back, silenced. What the #$?!#$ the TA said. I typed, I said leave me alone! The student got real upset. I didn't do anything to it, I swear! It was all I could do to keep from laughing out loud. The conversation between them and HAL 2000 went on for an amazing five minutes. Me: Don't touch me! Student: I m sorry, I didn't mean to hit your keys that hard. Me: Who do you think you are anyway?! Etc. Finally, I couldn t contain myself any longer and fell out of my chair laughing. After they had realized what I had done, they both turned beet red. Funny, I never got more than a C- in that class. Page 9/11

5. (23 points) Deadlock: Consider the following snapshot of a system. There are no current outstanding queued unsatisfied requests. currently available resources r1 r2 r3 r4 2 1 0 0 current allocation max demand still needs process r1 r2 r3 r4 r1 r2 r3 r4 r1 r2 r3 r4 p1 0 0 1 2 0 0 1 2 p2 2 0 0 0 2 7 5 0 p3 2 3 5 4 4 3 5 6 p4 2 3 5 4 4 3 5 6 p5 0 3 3 2 0 6 5 2 a. (5 points) Compute what each process still might request and fill in the still needs columns. b. (8 points) Is this system currently deadlocked, or will any process become deadlocked? Why or why not? If not, give an execution order. c. (10 points) If a request from p3 arrives for (0, 1, 0, 0). can that request be safely granted immediately? In what state (deadlocked, safe, unsafe) would immediately granting the whole request leave the system? Which processes, if any, are or may become deadlocked if this whole request is granted immediately? Page 10/11

This page intentionally left blank. Page 11/11