Vehicle tasks using semaphores, Operating System

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 their leisure, then line up for the cart ride. When a cart is
available, it allows the single passenger to climb aboard and drives around the habitat for a random amount of time. If the n carts are all taken, then a future rider waits; if a vehicle is available but no one is waiting, then the vehicle waits.
The solution to this problem must synchronize visitor tasks and vehicle tasks using semaphores.
Below is a potential solution. Correct any issues with this code, if any exist.
Explain your position in detail.

Semaphore vehicleAvailable = 0, vehicleTaken = 0, vehicleFilled = 0, visitorReleased = 0;

Visitor()

{
vehicleAvailable.wait();
vehicleTaken.signal();
vehicleFilled.wait();
visitorReleased.wait();

}

Vehicle()

{
while(True)
{

vehicleAvailable.signal();
vehicleTaken.wait();
vehicleFilled.signal();
Drive through habitat for some arbitrary amount of time;
visitorReleased.signal();

}
}

Posted Date: 3/15/2013 6:34:24 AM | Location : United States







Related Discussions:- Vehicle tasks using semaphores, Assignment Help, Ask Question on Vehicle tasks using semaphores, Get Answer, Expert's Help, Vehicle tasks using semaphores Discussions

Write discussion on Vehicle tasks using semaphores
Your posts are moderated
Related Questions
Q. Explain about diffrent Process State? Process State When process executes, it changes its state. Process state is defined as the current activity of the process. Fi

breifly write a note on about evolution of operating system?

Explain DosCreateThread Functions Used in the OS/2  DosCreateThread(&threadID,MyThreadFunction,arg,flags,stackSize) DosCreateThread creates a thread within the context of th

What is paging? Paging is a memory management scheme that authorizes the physical-address space of a process to be noncontiguous. Paging evades the considerable problem of fi

What do you mean by system calls? System calls give the interface among a process and the operating system. When a system call is implemented, it is treated as by the hardware

Q. Explain about Error detection method? Error detection: error can occur in CPU, in I/O devices or in memory hardware. Operating system constantly needs to be aware of possi

Differentiate pre-emptive and non-preemptive scheduling In a pre-emptive scheduling technique, CPU can be taken away from a process if there is a requirement while in a non-pre



As mentioned earlier, the game engine will be used as the base of developing the Go game for the Android. This includes improving logic of the game, design good graphics and optim