CS162 OS Midterm Exam #1, UC Berkeley, Sept 1999, Exams of Operating Systems

The cs162 operating systems midterm exam #1 held at the university of california, berkeley in september 1999. The exam covers topics such as threads, thread state transitions, concurrency control, and concurrency problems. Students are required to answer multiple-choice questions and provide solutions to programming problems.

Typology: Exams

2012/2013

Uploaded on 04/02/2013

shailesh_pr1c
shailesh_pr1c 🇮🇳

4.7

(7)

60 documents

1 / 10

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Page 1/10
University of California, Berkeley
College of Engineering
Computer Science Division EECS
Fall 1999 Anthony D. Joseph
Midterm Exam #1
September 29, 1999
CS162 Operating Systems
Your Name:
SID and 162 Login:
TA:
Discussion Section:
General Information:
This is a closed book examination. You have two hours 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
15
3
9
4
24
5
30
6
10
Total
100
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download CS162 OS Midterm Exam #1, UC Berkeley, Sept 1999 and more Exams Operating Systems in PDF only on Docsity!

University of California, Berkeley College of Engineering Computer Science Division – EECS

Fall 1999 Anthony D. Joseph

Midterm Exam

September 29, 1999 CS162 Operating Systems

Your Name:

SID and 162 Login:

TA:

Discussion Section:

General Information: This is a closed book examination. You have two hours 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^15

3^9

4^24

Total 100

  1. Threads – Good or bad? (12 points total): a. (6 points) List two reasons why overuse of threads is bad (i.e., using too many threads for different tasks). Be explicit in your answers. i)

ii)

b. (6 points) List two reasons why threads are useful/important. i)

ii)

  1. (24 points) Concurrency control: You’ve been hired by the HAL computer company to review their code for a large application. In the application you find the atomic swap procedure. Say whether it 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 may be several errors) and rewrite the code to fix it so it does work.

The problem statement is as follows: The atomic swap routine pops an item from each of two stacks and pushes the items onto the opposite stack. If either stack does not contain an item, the swap fails and the stacks are left as before the swap was attempted. The swap must appear to occur atomically: there should be no interval of time during which an external thread can determine that an item has been removed from one stack but not yet pushed onto another one. In addition, the implementation must be highly concurrent – it must allow multiple swaps between unrelated stacks to happen in parallel. You may assume that stack1 and stack2 never refer to the same stack.

void AtomicSwap (Stack *stack1, stack2) { Item thing1; / First thing being transferred / Item thing2; / Second thing being transferred */

stack1->lock.Acquire(); thing1 = stack1->Pop(); if (thing1 != NULL) { stack2->lock.Acquire(); thing2 = stack2->Pop(); if (thing2 != NULL) { stack2->Push(thing1); stack1->Push(thing2); stack2->lock.Release(); stack1->lock.Release(); } } }

(Additional space for question 4)

(Additional space for question 5)

No Credit – Problem X: (000000000000 points)

Runner up for the 1999 Darwin Awards ( don’t try this at home )

In rural Carbon County, PA, a group of men were drinking beer and discharging firearms from the rear deck of a home owned by Irving Michaels, age 27. The men were firing at a raccoon that was wandering by, but the beer apparently impaired their aim and, despite the estimated 35 shots the group fired, the animal escaped into a 3 foot diameter drainage pipe some 100 feet away from Mr .Michaels’ deck.

Determined to terminate the animal, Mr. Michaels retrieved a can of gasoline and poured some down the pipe, intending to smoke the animal out. After several unsuccessful attempts to ignite the fuel, Michaels emptied the entire 5-gallon fuel can down the pipe and tried to ignite it again, to no avail. Not one to admit defeat by wildlife, the determined Mr. Michaels proceeded to slide feet-first approximately 15 feet down the sloping pipe to toss the match.

The subsequent rapidly expanding fireball propelled Mr. Michaels back the way he had come, although at a much higher rate of speed. He exited the angled pipe “like a Polaris missile leaves a submarine,” according to witness Joseph McFadden, 31. Mr. Michaels was launched directly over his own home, right over the heads of his astonished friends, onto his front lawn. In all, he traveled over 200 feet through the air. “There was a Doppler Effect to his scream as he flew over us,” McFadden reported, “followed by a loud thud.” Amazingly, he suffered only minor injuries. “It was actually pretty cool,” Michaels said, “Like when they shoot someone out of a cannon at the circus. I’d do it again if I was sure I wouldn’t get hurt.”

(This page intentionally left blank)