Semaphore examples, Operating System

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();
}
}
Posted Date: 11/1/2012 9:12:47 AM | Location : United States







Related Discussions:- Semaphore examples, Assignment Help, Ask Question on Semaphore examples, Get Answer, Expert's Help, Semaphore examples Discussions

Write discussion on Semaphore examples
Your posts are moderated
Related Questions
General Graph Directory A serious trouble with using an acyclic graph structure is making sure that there are no cycles. When links are further added to an existing tree struc

how do semaphores help us in eliminating deadlock conditions?

Describe the purpose of the checkpoint mechanism. How habitually must checkpoints be performed? Explain how the frequency of checkpoints affects: System performance while no

Is disk scheduling, other than FCFS scheduling, useful in a single-user environment? Explain your answer. In a single-user environment, the I/O queue usually is blank. Requests

When we download a movie from the Internet, we don't care about, say, packet sizes. However, even ifwe are not aware of howlow-level details of networks are implemented, our data i

how to move the system app to usb storage

ADVANTAGES AND INCONVENIENCES OF KLT Advantages: the kernel be able to simultaneously schedule many threads of the same process on many processors blocking

Write a short note about context switch. Switching the CPU to another process needs saving the state of the old process and loading the saved state for the new process. This ta

We have talked about blocking locks, which voluntarily yield, and spinlocks, which just spin until they acquire the lock. At ?rst, it seems like spinlocks are verywasteful, and tha

basic advantage of using interrupt initiated data transfer over transfer under program control without an interrupt