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. Several CPU-scheduling algorithms are parameterized for instance the RR algorithm requires a parameter to indicate the time slice. Multilevel response queues require parameters

Characteristics of suspend process Suspended process isn't immediately available for execution. The process may or may not be waiting on an event. For preventing t

Q. Compare the utilization of networking sockets with the use of shared memory as a mechanism for communicating data between processes on a single computer. What are the merits of

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

explain about oprating system services and topics briefly

When a program issues a memory load or store operation, the virtual addresses (VAs) used in those operations have to be translated into "real" physical memory addresses (PAs). This

This exercise uses a graph-plotting program ( gnuplot ) to convert tabular data into an image. This is a technique that is very widely used to visualize scientific data; with app

please help us to write a code in c for tree directory structures.

Q. If each the access rights to an object are deleted the object can no longer be accessed. At this stage the object should also be deleted and the space it occupies should be ret

Explian Integrating a Request/Response Mechanism Traditional application developers will need to develop a mechanism for communication between requesting (client) and respondin