Tuesday, January 15, 2008

assignment#4

1. What are the major difference between deadlock, starvation, and race?

Deadlock
describes a situation where two or more threads are blocked forever, waiting for each other
Starvation is the result of conservative allocation of resources which a single job is prevented from execution because its kept waiting for resources that never become available.
Race is a synchronization problem between two processes vying for the same resource.

2. real life examples of deadlock, starvation and race.

Deadlock: When two basketball player are about to shoot in one basket in a practice game.
Starvation: When a person suitoring a girl while the girl has a boyfriend already.

Race: When two girls have the same boyfriend.

3. Four necessary condition needed for the deadlock from exercise #2:
if the product is only one.
if the two person needed that one product urgently.
if there's other alternative products available.
if the two person are brand conscious and the product happen to be what they like.
4.


5. figure 5.16 shows a tunnel going trough a mountain and two streets parallel to each other- one at each intrance/exit of the tunnel. Traffic light are located at each end of the tunnel to control the crossflow of tghe traffic through each intersection.
a. Deadlock will not happen because there are two traffic lights that control the traffic.The deadlock may when some of the motorist dont follow the traffic light because there's only one bridge to drive through.
b. Deadlock can be detected when there will be a huge bumper to bumper to the traffic and there will be accident that will happen.
c. The solution to prevent deadlock is that, the traffic lights should be accurate and motorist should follow it. In order to have a nice driving through the bridge.

6. Based on figure 5.17 answer the following question.
a. is this system deadlock?
-this is an deadlock because P2 still requesting or waitng for R1 that has already been allocated.

No comments: