Docsity

Homework Sample Questions - Operating Systems | ECS 251, Assignments of Operating Systems

Toggle sidebar
bg1
January 25, 2000 ECS 251 – Winter 2000 Page 1
Last modified at 10:55 pm on Tuesday, January 25, 2000
Homework #1
Due Date
: Tuesday, February 8, 2000 at 11:59PM
Points
: 100
1. (
20 points
) The following table shows domains and ranges for a system of processes along with known prece-
dence constraints:
process
p
1
p
2
p
3
p
4
p
5
p
6
p
7
domain
v
5
v
1
,
v
7
v
4
v
4
,
v
8
v
2
v
3
v
4
range
v
4
,
v
7
v
5
v
6
v
2
v
1
,
v
3
v
5
v
5
,
v
8
preceded by
p
1
p
1
p
2
p
3
p
3
p
4
,
p
6
Add the minimum number of precedence constraints to make this system of processes determinate. Do not
remove any constraints.
2. (
26 points
) For a semaphore
s
, define:
init
[
s
] is the initial value of
s
;
start_down
[
s
] is the number of times
down
(
s
) has been started;
end_down
[
s
] is the number of times
down
(
s
) has been completed; and
end_up
[
s
] is the number of times
up
(
s
) has been completed.
A useful semaphore invariant is:
end_down
[
s
] = min(
start_down
[
s
],
init
[
s
] +
end_up
[
s
]);
Show that
0
≤
end_down
[
empty
] –
end_down
[
full
]
≤
n
for the version of the producer-consumer solution using semaphores in the handout
Process Synchronization
and Communication
, p. 11.
3. (
14 points
) Indicate how each of the following items could be incorporated in the monitor mechanism (a sentence
or two for each is sufficient; you do not have to show an implementation).
a. type of request
b. times at which the requests were made
c. request parameters
d. process information
e. priority relation
f. local state of resource
g. history information
4. (
20 points
) Show that the
ordered request policy
of Havender prevents deadlocks (text, problem 3.4).
5. (
20 points
) Given that the mutual exclusion, hold and wait, and no preemption conditions are in place, consider
the following strategy: All processes are given unique priorities. When more than one process is waiting for a
resource and the resource becomes available, allocate the resource to the waiting process with the highest prior-
ity. Either prove this prevents deadlock or give an example in which this strategy does not prevent deadlock.
Extra Credit
6. (
10 points
) (Tanenbaum) Cinderella and the Prince are getting divorced. To divide their property, they have
agreed on the following algorithm. Every morning, each one may send a letter to the other's lawyer requesting
one item of property. Since it takes a day for letters to be delivered, they have agreed that if both discover that
they have requested the same item on the same day, the next day they will send a letter cancelling the request.
Among their property is their dog, Woofer, Woofer's doghouse, their canary Tweeter, and Tweeter's cage. The
animals love their houses, so it has been agreed that any division of property separating an animal from its house
is invalid, requiring the whole division to start over from scratch. Both Cinderella and the Prince desperately
want Woofer. So they can go on (separate) vacations, each spouse has programmed a personal computer to han-
dle the negotiation. When they come back from vacation, the computers are still negotiating. Why? Is deadlock
possible? Starvation? Discuss.

Partial preview of the text

Download Homework Sample Questions - Operating Systems | ECS 251 and more Assignments Operating Systems in PDF only on Docsity!

January 25, 2000 ECS 251 – Winter 2000 Page 1

Last modified at 10:55 pm on Tuesday, January 25, 2000

Homework

Due Date : Tuesday, February 8, 2000 at 11:59PM Points : 100

  1. ( 20 points ) The following table shows domains and ranges for a system of processes along with known prece- dence constraints: process p 1 p 2 p 3 p 4 p 5 p 6 p 7 domain v 5 v 1 , v 7 v 4 v 4 , v 8 v 2 v 3 v 4 range v 4 , v 7 v 5 v 6 v 2 v 1 , v 3 v 5 v 5 , v 8 preceded by p 1 p 1 p 2 p 3 p 3 p 4 , p 6 Add the minimum number of precedence constraints to make this system of processes determinate. Do not remove any constraints.
  2. ( 26 points ) For a semaphore s , define: init [ s ] is the initial value of s ; start_down [ s ] is the number of times down ( s ) has been started; end_down [ s ] is the number of times down ( s ) has been completed; and end_up [ s ] is the number of times up ( s ) has been completed. A useful semaphore invariant is: end_down [ s ] = min( start_down [ s ], init [ s ] + end_up [ s ]); Show that 0 ≤ end_down [ empty ] – end_down [ full ] ≤ n for the version of the producer-consumer solution using semaphores in the handout Process Synchronization and Communication , p. 11.
  3. ( 14 points ) Indicate how each of the following items could be incorporated in the monitor mechanism (a sentence or two for each is sufficient; you do not have to show an implementation). a. type of request b. times at which the requests were made c. request parameters d. process information e. priority relation f. local state of resource g. history information
  4. ( 20 points ) Show that the ordered request policy of Havender prevents deadlocks (text, problem 3.4).
  5. ( 20 points ) Given that the mutual exclusion, hold and wait, and no preemption conditions are in place, consider the following strategy: All processes are given unique priorities. When more than one process is waiting for a resource and the resource becomes available, allocate the resource to the waiting process with the highest prior- ity. Either prove this prevents deadlock or give an example in which this strategy does not prevent deadlock.

Extra Credit

  1. ( 10 points ) (Tanenbaum) Cinderella and the Prince are getting divorced. To divide their property, they have agreed on the following algorithm. Every morning, each one may send a letter to the other's lawyer requesting one item of property. Since it takes a day for letters to be delivered, they have agreed that if both discover that they have requested the same item on the same day, the next day they will send a letter cancelling the request. Among their property is their dog, Woofer, Woofer's doghouse, their canary Tweeter, and Tweeter's cage. The animals love their houses, so it has been agreed that any division of property separating an animal from its house is invalid, requiring the whole division to start over from scratch. Both Cinderella and the Prince desperately want Woofer. So they can go on (separate) vacations, each spouse has programmed a personal computer to han- dle the negotiation. When they come back from vacation, the computers are still negotiating. Why? Is deadlock possible? Starvation? Discuss.