Correct the code for visitor and vehicle portion, 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, a single passenger may climb aboard and drive 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 for the Visitor and Vehicle portions (assume that other portions of the system admit the tasks to the system). 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/25/2013 2:10:11 AM | Location : United States







Related Discussions:- Correct the code for visitor and vehicle portion, Assignment Help, Ask Question on Correct the code for visitor and vehicle portion, Get Answer, Expert's Help, Correct the code for visitor and vehicle portion Discussions

Write discussion on Correct the code for visitor and vehicle portion
Your posts are moderated
Related Questions
Q. Can a system detect that some of its processes are starving? If you answer "yes," explain how it can. If you answer "no," explain how the system can deal with the starvation pro


Question : a) Consider table 1.0 below, assume the processes arrived in the order P 1 , P 2 , P 3 , P 4 at time shown and need the indicated burst time (both in milliseconds)


What are the advantages of multi threading?  Multithreading a code can have several advantages. Improve application responsiveness --Any program in which var

What are the objectives and functions of operating system? Functions of operating systems 1.      It allocates the resources and acts as a supervisor. 2.      It hides th

Define Page stealing    Page stealing is taking page frames another working sets

What is critical section? Every process has a segment code called the critical section, in which the process may be updating tables, changing variables, writing file and etc. W

What is the sequence in which resources may be utilized? Under normal mode of operation, a process may utilize a resource in the following sequence: Request: If the requ

Write a XML with database with book details (BOOK ID, Title, Author, subject, publisher year, language, vendor, and price)