Answer the following: Gopher Gallery consists of a shopping mall and a cart ride
ID: 3545579 • Letter: A
Question
Answer the following:
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();
}
}
Explanation / Answer
In computer science, particularly in operating systems, a semaphore is a variable or abstract data type that is used for controlling access, by multiple processes, to a common resource in a parallel programming or a multi user environment.In this case vechile is a semaphore. In this case you can use Binary Semaphores.It can hold either 0 or 1 in any given case. According the above pseudo code, if a vehicle is available then its ta taken and will signal and put the other semaphores on wait. Same applies to visitor also. Also the pseudo code seems to be correct and doesnt require any modifications.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.