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. Polling for an I/O completion is able to waste a large number of CPU cycles if the processor iterates a busy-waiting loop several times before the I/O completes. However if the

What are the methods for handling deadlocks ? The technique for handling the deadlocks are: We are able to use protocol to prevent or avoid the deadlock, make sure tha

Describe the differences between symmetric and asymmetric multiprocessing. What are three advantages and one disadvantage of multiprocessor systems? Symmetric multiprocessing t


Question: Introduction to Operating Systems a) Define the term ‘Operating System' and identify main functions of an operating system. b) What are the characteristics of a go

Define busy waiting and spinlock. When a process is in its significant section, any other process that tries to enter its critical section must loop continuously in the entry c

What are the functions of virtual file system (VFS)? a. It separates file-system-generic operations from their execution defining a clean VFS interface. It permits transparent

Define the Global vs. local variables It is also important to discuss the scope of resources being granted to the application program.  Variable scoping is defined as the acces

Q. What is the major difficulty that a programmer should overcome in writing an operating system for a real-time environment? Answer: The major difficulty is keeping the oper

KERNEL ACTIVITY FOR ULTS: The kernel isn't aware of thread activity but it is still managing process activity. When a thread compose a system call the whole process will be bl