Gopher Gallery consists of a shopping mall and a cart ride that covers the 150 acre habitat. There are m visitors and n single-person vehicles. Visitors stroll around the mall at their leisure, then line up for the cart ride. When a cart is available, a single passenger may climb aboard and drive around the habitat for a random amount of time. If the n carts are all taken, then a future rider waits; if a vehicle is available but no one is waiting, then the vehicle waits. The solution to this problem must synchronize visitor tasks and vehicle tasks using semaphores. Below is a potential solution for the Visitor and Vehicle portions (assume that other portions of the system admit the tasks to the system). Correct any issues with this code, if any exist. Explain your position in detail.
Semaphore vehicleAvailable = 0, vehicleTaken = 0, vehicleFilled = 0,
visitorReleased = 0;
Visitor()
{
vehicleAvailable.wait();
vehicleTaken.signal();
vehicleFilled.wait();
visitorReleased.wait();
}
Vehicle()
{
while(True)
{
vehicleAvailable.signal();
vehicleTaken.wait();
vehicleFilled.signal();
Drive through habitat for some arbitrary amount of time;
visitorReleased.signal();
}
}