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
how does DMA increase system concurrency

Concept of Reentrancy   It is a useful, memory-saving method for multiprogrammed timesharing machines. A Reentrant method is one in which multiple clients can share a singl

Question : a) Consider table 1.0 below, assume the processes arrived in the order P 1 , P 2 , P 3 , P 4 at time shown and need the indicated burst time (both in milliseconds)

A UNIX file system has 1-KB blocks and 4-byte disk addresses. What is the maximum file size if i-nodes contains 10 direct entries, and one single, double, and triple indirect entry

What are the features of Operation Research approach?

List out the advantages of windows 2000 file management. Permits detailed security for individual folders and files. Built-in granular compression capabilities

What are the four necessary conditions of deadlock prevention?       Ans:  Four essential conditions for deadlock prevention: a. The meaning of removing the mutual exclusio

What is critical section? Every process has a segment code called the critical section, in which the process may be updating tables, changing variables, writing file and etc. W

Question 1: a) Distinguish between "Long-Term Scheduler" and "Short-Term Scheduler". b) Describe the benefits of "Threads". c) Name three types of CPU Scheduling. Que

Gopher Gallery consists of a shopping mall and a cart ride that covers  the 150 acre habitat. There are m visitors and n single-person vehicles. Visitors  stroll around the mall at