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
Q. Compare the utilization of networking sockets with the use of shared memory as a mechanism for communicating data between processes on a single computer. What are the merits of

At the end of this lecture, and into the next lecture, we will discuss the last major type of logical error that can occurwhen programming with threads. A deadlock occurswhen two t

In a  p system each part (RAM, ROM, I/O) has a unique set of numbers. The allocation of these numbers is usually stated in the form of a memory map. This is a plot of data bus agai

LINUX VS WINDOWS I/O MANAGEMENT

What are the requirements to be satisfied by the critical section problem? Following are the necessities to be satisfied by the critical section problem: a)      Mutual exc

LINUX OPERATING SYSTEM 1. Write a brief explanation about the Linux distribution. 2. Explain the features that Bash shell provides? 3. Who is responsible for managing use

One reason to learn C and C++ is simply that so much software is written in these languages. A related, butmore fundamental reason, is that C and C++ are relatively low-level, allo

Q. What is the major advantage of the layered approach to system design? What are the de-merits of using the layered approach? Answer: As in all cases of modular design as well

What are the five major activities of an operating system in regard to process management? The creation and deletion of both user and system processes The suspension and res

What are the various disk-scheduling algorithms? The several disk-scheduling algorithms are a. First Come First Served Scheduling b. Shortest Seek Time First Scheduling