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. Under what conditions do page faults occur? Explain the actions taken by the operating system when a page fault occurs. Answer: A page fault take places when an access to

Logical File System Responsible for providing the before discussed interface to the user including: File access. Directory operations. Security and protection.


Q. Process migration in a heterogeneous network is typically impossible given the differences in architectures and operating systems. Explain a method for process migration across


Define Segmentation  The memory allocation method subject to “external” fragmentation is Segmentation.

There is a very small amount of networking background required for Project 2. In Project 2, we want our computer (or our "host") to request information over the Internet from a rem

how do semaphores help us in eliminating deadlock conditions?

Device Drivers Communicates straight with peripheral devices (disks, tapes, etc.). Responsible for begin physical I/O operations on the device. Pro

Write a note on deadlocks. The proper definition of deadlock A set of processes is deadlocked if every process in the set is waiting for an event that only a proces