Operating System Concepts, Seventh Edition

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
Page 1/19 University of California, Berkeley College of Engineering Computer Science Division EECS Fall 2006 John Kubiatowicz Midterm I October 11 th , 2006 CS162: Operating Systems and Systems Programming Your Name: SID Number: Discussion Section: General Information: This is a closed book exam. You are allowed 1 page of hand-written notes (both sides). You have 3 hours to complete as much of the exam as possible. Make sure to read all of the questions first, 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. On programming questions, we will be looking for performance as well as correctness, so think through your answers carefully. If there is something about the questions that you believe is open to interpretation, please ask us about it! Problem Possible Score 1 20 2 24 3 19 4 20 5 17 Total 100
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CS 162 Fall 2006 Midterm Exam I October 11, 2006 Page 2/19 [ This page left for π ] 3.141592653589793238462643383279502884197169399375105820974944
Background image of page 2
CS 162 Fall 2006 Midterm Exam I October 11, 2006 Page 3/19 Problem 1: Short Answer [20pts] Problem 1a[2pts]: What is a virtual machine? Problem 1b[2pts]: Does a cyclic dependency always lead to deadlock? Why or why not? Problem 1c[2pts]: What are exceptions? Name two different types of exceptions and give an example of each type: Problem 1d[2pts]: List two reasons why overuse of threads is bad (i.e. using too many threads for different tasks). Be explicit in your answers.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CS 162 Fall 2006 Midterm Exam I October 11, 2006 Page 4/19 Problem 1e[3pts]: For each of the following thread state transitions, say whether the transition is legal and how the transition occurs or why itcannot. Assume Mesa-style monitors. 1). Change from thread state BLOCKED to thread state RUNNING 2). Change from thread state RUNNING to thread state BLOCKED 3). Change from thread state RUNNABLE to thread state BLOCKED Problem 1f[4pts]: Consider the Dining Lawyers problem, in which a set of lawyers sit around a table with one chopstick between each of them. Let the lawyers be numbered from 0 to n-1 and be represented by separate threads. Each lawyer executes Dine(i) , where “ i ” is the lawyer’s number. Assume that there is an array of semaphores, Chop[i] that represents the chopstick to the left of lawyer i. These semaphores are initialized to 1. void Dine(int i) { Chop[i].P(); /* Grab left chopstick */ Chop[(i+1)%n].P(); /* Grab right chopstick */ EatAsMuchAsYouCan(); Chop[i].V(); /* Release left chopstick */ Chop[(i+1)%n].V(); /* Release right chopstick */ } This solution can deadlock. Assume that it does. List the four conditions of deadlock and explain why each of them is satisfied during the deadlock:
Background image of page 4
CS 162 Fall 2006 Midterm Exam I October 11, 2006 Page 5/19 Problem 1g[3pt]: Pick one of the above four conditions and rewrite the code to eliminate it. Identify the condition you chose carefully and explain why your code doesn’t deadlock:
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

This homework help was uploaded on 01/30/2008 for the course CS 162 taught by Professor Kubiatowicz during the Fall '02 term at University of California, Berkeley.

Page1 / 19

Fa06 midterm 1 - University of California, Berkeley College...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online