ok so i think i got this right by not 100 on this


Ok so i think i got this right by not 100% on this. what I want to figure out is if there are x visitors that can line up for a ride but only 1 passenger can get on the ride at a time when the ride is available. If y number of rides are taken, the visitors have to wait for a ride to become available. If the ride is available but no visitor is then the ride waits.

So this is what i got so far this is all just psudo code I dont really need this to work I just need to wrap my head around the semaphore thing

Semaphore rideAvaliable = 0. rideTaken = 0, rideFilled = 0, visitorReleased = 0;


Visitor()
{
rideAvaliable.wait();
rideTaken.signal();
rideFilled.wait();
visitorReleased.wait();
}

Vehicle()
{
while(TRUE)
{
rideAvaliable.signal();
rideTaken.wait();
ride.Filled.signal();
Drive around for a bit
visitorReleased.signal();
}
}

Request for Solution File

Ask an Expert for Answer!!
Operating System: ok so i think i got this right by not 100 on this
Reference No:- TGS0176816

Expected delivery within 24 Hours