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.  To build a vigorous distributed system you must know what kinds of failures can occur. a. List three possible kinds of failure in a distributed system. b. State which of

Using pages makes it easier to manage the whole memory, avoiding excessive fragmentation and waste. As an analogy, think of Tetris, but with only square blocks: it is relatively ea

Question 3: (a) Fincorp Ltd is an insurance company wishing to change over to a better business system using an improved version of a financial information system (FIS). The direc

What are the various page replacement algorithms used for page replacement? FIFO page replacement Optimal page replacement LRU page replacement LRU approximat

Q. A Burroughs B7000/B6000 MCP file is able to be tagged as sensitive data. When such a file is removed its storage area is overwritten by some random bits. For what reason would

Resolution of externally defined symbols is carried out by    Resolution of externally defined symbols is carried out by Linker

Networks and operating systems have a lot of overlap. In this course, however,we are not going to discuss networking in detail, but rather focus on the networking abstractions prov

Define which is not a key piece of information, stored in single page table entry, supposing pure paging and virtual memory  A reference for the disk block which stores the pa

What are the differences between process and thread? The fundamental difference between a process and a thread is that a process has an entire copy of the program to itself and