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
EXAMPLE FOR SEGMENTATION Consider an instance as given in the table and we have five segments numbered from 0 through 4 the segment is stock in the physical memory as shown. Th

what are the overall concepts of deadlock

Developing an application for android encompass different steps as follows: Setup:  Development environment is prepared during this phase. This includes downloading and installi

Q. Remapping of bad blocks by sector sparing or else sector slipping could influence performance. Presume that the drive in Subsequent Exercise has a total of 100 bad sectors at r

Interrupts The hardware mechanism that enables a device to inform the CPU is called an interrupt. The basic interrupt mechanism works as follows. The CPU hardware has a wire kn

The following is a dump of a TCP header in hexadecimal format: 00CD0018 00000EF1 00000D5D 502200D1 01BF0010 We need to first split the above hex as such 00 CD 00 18 00 00

How do we overcome the disadvantages of the two-level directory? Give links from one user directory to another, creating path names; system files become available by letting th

Process Description A process in UNIX is a somewhat complex set of data structures that provides the operating system with all of the information necessary to dispatch and manag

Differentiate between sequential access and direct access method?

What is an operating system process? How is it different from a program? Why do we need the concept of a process, rather than simply talk about programs running in memory? The e