Semaphore examples, Operating System

Assignment Help:
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();
}
}

Related Discussions:- Semaphore examples

All the explanations of operating system and its types., operating systems ...

operating systems and its types together with its design issues and their examples.

What is meant by the term affinity in processor sheduling, Question: (a...

Question: (a) Answer the following questions based on the code snippet below. 1. int main (int argc, char *argv[]) 2. { 3. 4. pid_t processId; 5. 6. processId =

Define maintaining data on a per client basis, Define Maintaining Data on a...

Define Maintaining Data on a Per Client Basis Perhaps the most dramatic syntactical programming change for the application developer of client – server applications is maintain

Name the hardware to support demand paging, The hardware to support demand ...

The hardware to support demand paging is as follows Page table: This table has the skill to mark an entry invalid though a valid-invalid bit or particular value of protectio

Evaluate the physical address, Compare between the one and two-dimensional ...

Compare between the one and two-dimensional memory organizations in terms of the  memory structure,  advantages, and disadvantages.  Which approach would better support the needs o

What are the different directory structures, What are the different directo...

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

What is the drawbacks of contiguous allocation of disk space, What are the ...

What are the drawbacks of contiguous allocation of disk space? The disadvantages are a. Suffers from internal fragmentation b. Suffers from external fragmentation c. F

Explian reference string, What is reference string We evaluate an algor...

What is reference string We evaluate an algorithm by running it on a definite string of memory reference and computing the number of page faults. The string of memory reference

Explain the tlssetvalue (tlsindex, Explain the TlsSetValue (TLSindex, dataP...

Explain the TlsSetValue (TLSindex, dataPtr)Function The TlsSetValue function  associates the  dataPtr passed as a parameter as local storage for the requesting thread. The asso

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd