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

Dynamic scheduling : The number of thread in a program may be changed during the course of operation. Dynamic priority scheduling is a kind of scheduling algorithm in which the pr

What are the different directory structures? Explain each type. There are five dissimilar directory structures: 1.      Single level directory 2.      Two level directory

Q. Describe the purpose of the open() and close() operations. Answer: The open() operation notifies the system that the named file is about to become active. The c

Question: a) Illustrate with the help of a diagram, the difference between two tier and three tier architectures. b) Explain in what kind of environment, a peer to peer envi

what are the design issues of network OS

Enhanced Second chance algorithm In this a modify bit is as well used. Now if the ordered pair of reference and modify is (0,0) neither recently used nor modified - the best

Q. What is Multiprogramming? Multiprogramming When two or more programs are in memory at the same instance, sharing the processor is referred to multiprogramming opera

socket based fortune teller sever.your program should create a server that listens to a specific port when a client receives a connection the server should respond with a random fo

In a multiprogramming and time sharing environment several users share the system simultaneously .what are two such problems?