Write a C program to simulate the following IPC problem Make
Write a C program to simulate the following IPC problem. Make sure to use semaphores to synchronize the processes/threads.
Jurassic Park consists of a dinosaur museum and a park for safari tiding. There are n passengers and m 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 m cars are all out riding passenger around, the 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 n passenger threads/processes and the m car threads/processes.
Solution
semaphores me = 1, mutex = n;
Solution 2:
Remember that P and V correspond to semWait and semSignal .
resource Jurassic_Park()
 sem car_avail := 0, car_taken := 0, car_filled := 0, passenger_released := 0
 process passenger(i := 1 to num_passengers)
 do true -> nap(int(random(1000*wander_time)))
 P(car_avail); V(car_taken); P(car_filled)
 P(passenger_released)
 od
 end passenger
 process car(j := 1 to num_cars)
 do true -> V(car_avail); P(car_taken); V(car_filled)
 nap(int(random(1000*ride_time)))
 V(passenger_released)
 od
 end car
 end Jurassic_Park
 Ignore syntax and missing variable declarations.

