






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
This is a midterm exam for cs162 operating systems course offered in spring 2008 at the university of california, berkeley. The exam covers topics such as deadlock, synchronization primitives, monitors, dining graduate students problem, and operating systems concepts.
Typology: Exams
1 / 12
This page cannot be seen from the preview
Don't miss anything!
University of California, Berkeley College of Engineering Computer Science Division – EECS
Spring 2008 Anthony D. Joseph
February 27, 2008 CS162 Operating Systems
Your Name:
SID AND 162 Login:
TA Name:
Discussion Section Time:
General Information: This is a closed book and notes examination. You have 90 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!
Problem Possible Score
TRUE FALSE Why?
b. (4 points) True/False and Why? In the operating system environments that we’ve studied so far (i.e., no virtual memory), the operating system has to worry about deadlock occurring involving physical memory as a resource.
TRUE FALSE Why?
c. (5 points) Disabling interrupts: i) (3 points) Give a two to three sentence description of how interrupts can be used to implement critical sections.
ii) (2 points) Briefly (2-3 sentences) state the problems with implementing critical sections using disabling of interrupts.
a. (6 points) While working on the first project, one of your project partners proposes to use a modified version of Semaphore to implement the condition variable class as follows:
Semaphore.set(0); // Initialize semaphore to 0 Wait(Lock lock) { Semaphore.P(lock); // Special semaphore that // releases lock if it waits }
Signal() { Semaphore.V(); }
Decide whether you think their proposal will work or not, and briefly, in two to three sentences, explain your decision
b. (9 points) Another one of your project partners proposes the opposite – to implement semaphores using an unmodified Mesa-style Monitor class. Show a possible implementation of a Semaphore class using monitors. You should provide the initialize(value), P(), and V() operations.
a. (4 points) Specify the correctness constraints. Be succinct and explicit in your answer.
b. (5 points) Can deadlock ever occur? Explain your answer in terms of the conditions for deadlock to occur. If deadlock could occur, describe a reasonable deadlock avoidance algorithm. If deadlock cannot occur, explain why not.
c. (8 points) Implement the Dine() method using only semaphores (your solution may not use locks, monitors, or other synchronization primitives). Create a method Dine(), which waits until a student has fork and knife and can eat, then calls Eat(), and then releases the utensils before returning. Your solution should allow multiple students to eat at the same time (as long as there are sufficient utensils in a pile in the middle of the table). Assume you are given the variables, forks and knifes, which each starts off initialized to the total number of forks and knives available, respectively. Based on your answer from part 3.b, your solution should avoid deadlock.
d. (6 points) We discussed the Therac-25 in lecture and in an assigned reading. i) What is the Therac-25, and how does it differ from the Therac-20?
ii) Explain the Therac-25’s problems and the underlying causes.
No Credit – Problem X (000000000000 points)
“Named in honor of Charles Darwin, the father of evolution, the Darwin Awards commemorate those who improve our gene pool by accidentally removing themselves from it.” (http://www.darwinawards.com/)
[Confirmed True]
(26 February 2007, California) 29-year-old Oscar was driving on Highway 99 near Yuba City, when his Honda Accord crossed into oncoming traffic and collided with a Hummer. The occupants of the Hummer were not seriously injured. California Highway Patrol officers found Oscar’s laptop still running, and plugged into the car’s cigarette lighter. Investigators believe that he was using it when his car crossed the center line.
“Driving is not a time to be practicing your multitasking skills,” remarked CHP spokesman Tom Marshall.
Oscar is not alone. Last year, 510 California drivers were charged with reckless driving because they were using a TV, video, or computer monitor. A 2001 CHP study cites cell phone use as the top cause of crashes involving distracted drivers, followed by fiddling with music. “Anything that distracts you can kill you, whether it’s eating lunch or working on a computer,” an AAA spokesman said.
Oscar was a computer tutor. Hopefully his fatal lesson will teach others to surf on the information superhighway, not the asphalt superhighway.