Analyze and correct psuedocode solution implementing synchronization with semaphores
$10-30 USD
Κλειστή
Αναρτήθηκε πάνω από 10 χρόνια πριν
$10-30 USD
Πληρωμή κατά την παράδοση
Bison World consists of a shopping mall and a buffalo 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 buffalo ride. When a buffalo vehicle is available, it allows the single passenger to climb aboard and drives around the habitat for a random amount of time. If the n buffalo vehicles 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. Assume initialization code exists. Correct any issues with this code, if any exist. Explain your position in detail.
Semaphore vehicleAvailable = 0, vehicleTaken = 0, vehicleFilled = 0,
visitorReleased = 0;
Visitor()
{
[login to view URL]();
[login to view URL]();
[login to view URL]();
[login to view URL]();
}
Vehicle()
{
while(True)
{
[login to view URL]();
[login to view URL]();
[login to view URL]();
Drive through habitat for some arbitrary amount of time;
[login to view URL]();
}
}