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
Explain the Spawnvp Function used in the netware Spawnvp(flags, execNmae, argv)   This function executes  similarly to spawnlp( ) except that parameters are passed as a v

Note that the parameter for scanf doesn't need the address operators & because name is an address. However the variable name has no defined space. This can cause problems within C

What are the system components of an operating system and explain them? a) Process management b) Main-memory management c) I/O management d) File management e) Seco

Present your own fully documented and tested programming example illustrating the problem of unbalanced loads. Describe the use of OpenMP's scheduler as a means of mitigating this

Linked list allocation using index The blocks don't have a fixed size. Pointers are utilized to point to the next block in a file. The pointers are set aside as a separate tabl

Direct memory access Many computers avoid burdening the main CPU with programmed I/O by offloading sine if this work to a special-purpose processor known as a direct memory add

Define CPU scheduling. CPU scheduling is the method of switching the CPU among several processes. CPU scheduling is the basis of multiprogrammed operating systems. By switching

Hierarchical paging Single way is to use a two-level paging algorithm, in which the page table itself is also paged. A logical address is separated into a page number and a pag

Explain multilevel feedback queue in detail A process can move among the various queues; aging can be executed this way Multilevel-feedback-queue scheduler explained b

Explain working of the logical file system The logical file system manages metadata information. Metadata contains all of the file-system structure, excluding actual data. It h