Waiting for answer This question has not been answered yet. You can hire a professional tutor to get the answer.

QUESTION

The following problem was once used on an exam: Jurassic Park consists of a dinosaur museum and a park for safari riding. There are m passengers and...

5.21. The following problem was once used on an exam:

Jurassic Park consists of a dinosaur museum and a park for safari riding. There are m passengers and n single-passenger cars. Passengers wander around the museum for a while, then line up to take a ride in a safari car. When a car is available, it loads the one passenger it can hold and rides around the park for a random amount of time. If the n cars are all out riding passengers around, then a passenger who wants to ride waits; if a car is ready to load but there are no waiting passengers, then the car waits. Use semaphores to synchronize the mpassenger processes and the n car processes.

The following skeleton code was found on a scrap of paper on the floor of the exam room. Grade it for correctness. Ignore syntax and missing variable declarations. Remember that P and V correspond to semWait and semSignal.

() sem car_avail := , car_taken := , car_filled := ,     passenger_released :=   ( to num_passengers)  -> ((random(*wander_time)))  (); V(car_taken); P(car_filled)  P(passenger_released) odend passengerprocess ( to num_cars)  -> (); P(car_taken); V(car_filled) nap((random(*ride_time))) V(passenger_released) od end carend Jurassic_Park
Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question