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

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

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

Midterm Exam March 3, 1999 CS162 Operating Systems

Midterm Exam #1 September 29, 1999 CS162 Operating Systems

COMP 3361: Operating Systems 1 Midterm Winter 2009

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

Midterm Exam March 13, 2013 CS162 Operating Systems

Midterm Exam Solutions March 7, 2001 CS162 Operating Systems

Midterm Exam October 15, 2012 CS162 Operating Systems

Lecture 9: Midterm Review

OPERATING SYSTEMS FINAL EXAMINATION APRIL 30, 2006 ANSWER ALL OF THE QUESTIONS BELOW.

Spring 2001 Midterm Exam, Anthony D. Joseph

CSE 451 Midterm Exam May 13 th, 2009

CS140 Operating Systems and Systems Programming Midterm Exam

CS162, Spring/1992 Midterm #2 Professor Thomas Anderson

Suggested Solutions (Midterm Exam October 27, 2005)

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

Filesystems (just a bit): File allocation tables, free-bitmaps, free-lists, inodes, and performance considerations.

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

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

Midterm Exam Amy Murphy 19 March 2003

Synchronization. CS61, Lecture 18. Prof. Stephen Chong November 3, 2011

Midterm Exam #2 April 20, 2016 CS162 Operating Systems

Midterm Exam March 7, 2001 CS162 Operating Systems

CPS 310 second midterm exam, 11/14/2014

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

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

CS 140 Midterm Examination Winter Quarter, 2012

Midterm Exam #1 September 28, 2016 CS162 Operating Systems

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

Midterm Exam #1 February 28, 2018 CS162 Operating Systems

CSE 153 Design of Operating Systems

CS 153 Design of Operating Systems Winter 2016

CS4411 Intro. to Operating Systems Exam 2 Fall 2009

CSCI 346 Final Exam Review Materials

PROCESS SYNCHRONIZATION

COS 318: Midterm Exam (October 23, 2012) (80 Minutes)

CS 318 Principles of Operating Systems

First Midterm Exam Solutions October 1, 2018 CS162 Operating Systems

CPS 110 Midterm. Spring 2011

CSE 451: Operating Systems Winter Lecture 7 Synchronization. Steve Gribble. Synchronization. Threads cooperate in multithreaded programs

Midterm Exam Amy Murphy 6 March 2002

COMP 3361: Operating Systems 1 Final Exam Winter 2009

This exam paper contains 8 questions (12 pages) Total 100 points. Please put your official name and NOT your assumed name. First Name: Last Name:

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

Last Class: Deadlocks. Today

First Midterm Exam September 28, 2017 CS162 Operating Systems

CPS 110 Problem Set #1

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

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

University of Waterloo Midterm Examination Model Solution CS350 Operating Systems

CSE 153 Design of Operating Systems

CSE 451: Operating Systems Winter Lecture 7 Synchronization. Hank Levy 412 Sieg Hall

Problem Max Points Score Total 100

CS 450 Exam 2 Mon. 11/7/2016

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

Lecture. DM510 - Operating Systems, Weekly Notes, Week 11/12, 2018

Second Midterm Exam March 21, 2017 CS162 Operating Systems

CSE 410 Final Exam 6/09/09. Suppose we have a memory and a direct-mapped cache with the following characteristics.

CS153: Midterm (Winter 19)

CSE 120 Principles of Computer Operating Systems Fall Quarter, 2002 Halloween Midterm Exam. Instructor: Geoffrey M. Voelker

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

CS140 Operating Systems and Systems Programming Midterm Exam

Midterm Exam. October 20th, Thursday NSC

CS 5523 Operating Systems: Midterm II - reivew Instructor: Dr. Tongping Liu Department Computer Science The University of Texas at San Antonio

CS-537: Midterm Exam (Spring 2001)

Operating Systems Comprehensive Exam. There are five questions on this exam. Please answer any four questions total

CS4411 Intro. to Operating Systems Exam 1 Fall points 9 pages

CPSC/ECE 3220 Summer 2017 Exam 2

Sections 01 (11:30), 02 (16:00), 03 (8:30) Ashraf Aboulnaga & Borzoo Bonakdarpour

Operating Systems (1DT020 & 1TT802)

CROWDMARK. Examination Midterm. Spring 2017 CS 350. Closed Book. Page 1 of 30. University of Waterloo CS350 Midterm Examination.

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

Chapter 5: Process Synchronization. Operating System Concepts Essentials 2 nd Edition

CS153: Midterm (Fall 16)

CS450 OPERATING SYSTEMS FINAL EXAM ANSWER KEY

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

CPSC/ECE 3220 Summer 2018 Exam 2 No Electronics.

CS 31: Introduction to Computer Systems : Threads & Synchronization April 16-18, 2019

Synchronization I. Jo, Heeseung

CS4411 Intro. to Operating Systems Exam 1 Fall points 10 pages

Process Management And Synchronization

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

Part II Process Management Chapter 6: Process Synchronization

Operating Systems. Operating Systems Summer 2017 Sina Meraji U of T

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

Midterm - Winter SE 350

CHAPTER 6: PROCESS SYNCHRONIZATION

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

Last Class: Synchronization Problems!

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

MCS-378 Intraterm Exam 1 Serial #:

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

Lecture 8: September 30

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

First Exam name: John Franco

CS350: Final Exam Review

Operating Systems EDA092, DIT 400 Exam

Chapter 6: Process Synchronization

Virtual Machine Design

Transcription:

CS 162 Midterm Exam October 18, 1993 Your Name: Lecture (A.M. or P.M.): General Information: This is a closed book examination. You have 60 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 60 points in all. Write all of your answers directly on this paper. Make your answers as concise as possible (you needn't cover every available nano-acre with writing). If there is something in a question that you believe is open to interpretation, then please go ahead and interpret BUT state your assumptions in your answer. Problem 1: (6 points) For each of the following statements, indicate in one sentence whether the statement is true or false, and why. (a) If a set of cooperating threads can correctly time-share one processor, then they will correctly execute on separate processors of a multiprocessor. (b) The CPU scheduling policy that minimizes average response time can never lead to starvation. (c) If a system employing only segmentation wants to enlarge an address space, it is always possible if the total amount of free memory is bigger than the requested enlargement. 1

Problem 2: (8 points) For each of the following items, write a one sentence denition: (a) Interrupt (b) Fully associative cache (c) Working set (d) Throughput Problem 3: (12 points) (a) What is the worst possible CPU scheduling algorithm { the one that yields the worst average response time? Assume that the algorithm must run a thread if there is one available, and that a context switch has zero overhead. 2

Problem 3 (cont'd): (b) Can round robin ever be the worst possible CPU scheduling algorithm? If so, under what circumstances? If not, explain why not. (c) Can FIFO ever be the worst possible CPU scheduling algorithm? If so, under what circumstances? If not, explain why not. Problem 4: (10 points) Consider the clock algorithm for page replacement, being used in its simplest form (\rst-chance" replacement, where the clock is only advanced on a page fault, not in the background). Suppose that there are P pages of physical memory in the system and that over a particular interval of time F page faults have occurred. Express the minimum and maximum number of times that the clock hand could possibly have been advanced during the time interval, as a function of P and F. (Don't worry about \o by one" errors, I'm just looking for the basic idea.) 3

Problem 5: (24 points) You have been hired by your professor to be a grader for CS 162. Below you will nd some sample solutions to a concurrency assignment. For each proposed solution, mark it either (i) \correct", if it has no aws, (ii) \incorrect", if it does not work, or (iii) \dangerous", if it sometimes works but sometimes doesn't. You may assume either Mesa-style or Hoare-style condition variables, but if it matters, you must say which one you are using. If the solution is incorrect or dangerous, explain everything wrong with the solution, and add a minimal amount of code to correct the problem. (NOTE: don't just implement a completely dierent solution { use the code we provide as a base.) Here is the synchronization problem: A particular river crossing is shared by both cannibals and missionaries. A boat is used to cross the river, but it only seats three people, and must always carry a full load. In order to guarantee the safety of the missionaries, you cannot put one missionary and two cannibals in the same boat (because the cannibals would gang up and eat the missionary), but all other combinations are legal. Two procedures are needed: MissionaryArrives and CannibalArrives, called by a missionary or cannibal when it arrives at the river bank. The procedures arrange the arriving missionaries and cannibals into safe boatloads; once the boat is full, one thread calls RowBoat and after the call to RowBoat, the three procedures then return. There should also be no undue waiting: missionaries and cannibals should not wait if there are enough of them for a safe boatload. 4

Here is one proposed solution: int nummissionaries = 0, numcannibals = 0; Lock *mutex; Condition *misswait, *cannwait; void RowBoat() {printf("row, row, row your boat"); void MissionaryArrives() { mutex->acquire(); if (nummissionaries == 2) { else if (nummissionaries == 1 && numcannibals == 1) { cannwait->signal(); else { nummissionaries++; missionarywait->wait(mutex); nummissionaries--; mutex->release(); void CannibalArrives() { mutex->acquire(); if (numcannibals == 2) { cannwait->signal(); cannwait->signal(); else if (nummissionaries == 2) { else { numcannibals++; cannwait->wait(mutex); numcannibals--; mutex->release(); 5

Here is another proposed solution (don't worry about the potential starvation due to the loop in PersonArrives { the scheduler causes lots of random timeslices!): Semaphore *boatcount = new Sempahore(3); // initial value = 3 int nummissionaries = 0, numcannibals = 0; Lock *boatlock; Condition *boatwait; bool success; void RowBoat() { success = TRUE; void MissionaryArrives() { PersonArrives(&numMissionaries); void CannibalArrives() { PersonArrives(&numCannibals); void PersonArrives(int *numpeople) { for (;;) { boatcount->p(); *numpeople++; if ((nummissionaries + numcannibals) < 3) { boatlock->acquire(); boatwait->wait(boatlock); else { if (!(nummissionaries == 1) && (numcannibals == 2)) else success = FALSE; boatwait->signal(); boatwait->signal(); numpeople->p(); boatcount->v(); if (success) return; Problem 6: Extra Credit (2 points) Give an engineering estimate (to within a factor of 2 or so) of the number of barbers and hairdressers in the United States. Explain your method. 6