Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Jurassic Park consists of a dinosaur museum and a park forsafari riding. There are m passengers and n single-passenger cars. Passengers wander aroundthe museum for

Jurassic Park consists of a dinosaur museum and a park forsafari riding. There are m  passengers and n single-passenger cars. Passengers wander aroundthe museum for a  while, then line up to take a ride in a safari car. When a car isavailable, it loads the  one passenger it can hold and rides around the park for a randomamount of time. If  the n cars are all out riding passengers around, then a passengerwho wants to ride  waits; if a car is ready to load but there are no waitingpassengers, then the car waits.  

Use semaphores to synchronize the m passenger processes and the ncar processes.  The following skeleton code was found on a scrap of paper on thefloor of the exam room.  (Note: W and S correspond to Wait and Signal. Additionally, thereis a process created for  each passenger and car.) Ignoring syntax and missing variabledeclarations,
a. Grade it for correctness (ie deadlock, starvation, mutualexclusion, etc.).
b. How does weak vs strong semaphores effect the rides?
c. How would you fix any problems?


resource Jurassic_Park()
sem car_avail := 0;
sem car_taken := 0;
sem car_filled := 0;
sem ride_done := 0;
process passenger(i := 1 to num_passengers)
do true ->
nap(int(random(1000*wander_time)));
W(car_avail);
S(car_taken);
W(car_filled);
W(ride_done);
od
end passenger
process car(j := 1 to num_cars)
do true ->
S(car_avail);
W(car_taken);
nap(int(random(10*fill_time)));
S(car_filled);
nap(int(ramdom(1000*ride_time)));
S(ride_done);
od
end car
end Jurassic_park

Step by Step Solution

3.34 Rating (166 Votes )

There are 3 Steps involved in it

Step: 1

solu... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microeconomics

Authors: Douglas Bernheim, Michael Whinston

2nd edition

73375853, 978-0073375854

More Books

Students also viewed these Accounting questions

Question

Show all the steps and calculations

Answered: 1 week ago

Question

Subtract the polynomials. (-x+x-5) - (x-x + 5)

Answered: 1 week ago