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
What is macro expansion

Q. Segmentation is alike to paging but uses variable-sized "pages". Describe two segment-replacement algorithms based on FIFO and LRU page replacement schemes. Remember that since

What do you mean by semaphore?  Semaphore : A synchronization variable that acquires on positive integer values. Invented by the Dijkstra P (semaphore): an atomic proce

what is meant by lazzy swapper

Problem 1. List out the conditions that result in Deadlock situations. Illustrate deadlock situation with a simple graphical notation Listing conditions for deadlock occu

What is a file? A file is a named collection of related information that is recorded on secondary storage. A file having either programs or data. A file has particular "structu

Q. Suppose that you want to utilize a paging algorithm that requires a reference bit (such as second-chance replacement or working-set model) however the hardware does not provide

Explain with an example the need of Shift Alteration in critical section problem? Consider processes P i and P j and consider the algorithm for P i and P j .

Demand paging gives that pages could only be brought into memory if the running process acts them. This is usually referred to as lazy evaluation as only those pages operated by

Perform alpha-beta pruning on the following tree. Put an "X" over each node that is pruned. Put the final value next to all other nodes. Indicate which action MAX should take: to B