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

What is the use of system calls, Q. What is the use of system calls? A...

Q. What is the use of system calls? Answer: System calls permit user-level processes to request services of the operating system.

Ipc, Explain in detail about ipc in linux

Explain in detail about ipc in linux

Fcfs scheduling algorithm, Q. Presume that the following processes arrive f...

Q. Presume that the following processes arrive for execution at the times indicated. Every process will run the listed amount of time. In responding the questions use non pre-empti

What kind of operating system is windows xp, Q.  What kind of operating sy...

Q.  What kind of operating system is Windows XP? Describe two of its major features. Answer: A 32 or 64 bit pre-emptive multitasking operating system supporting multiple use

Define the dosexit function used in the os/2, Define the DosExit Function u...

Define the DosExit Function used in the OS/2 DosExit(action, resultCode)  DosExit function is to be called when a thread or process is finished executing. If EXIT_THREAD is

Explain the exitthread function used in the windows nt, Explain the ExitThr...

Explain the ExitThread Function used in the Windows NT ExitThread(ExitCode) The ExitThread( ) call is made to end the currently running thread. If the current thread is th

What is logical address space and physical address space, What is logical a...

What is logical address space and physical address space? The set of all logical addresses formed by a program is known as a logical address space; the set of all physical addr

Define busy waiting and spinlock, Define busy waiting and spinlock. Whe...

Define busy waiting and spinlock. When a process is in its significant section, any other process that tries to enter its critical section must loop continuously in the entry c

Define thrashing, Define thrashing. Thrashing is the accident of high p...

Define thrashing. Thrashing is the accident of high page traffic and low CPU utilization. It is observed that the cause of thrashing is an under-commitment of memory to program

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