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
File Organization     * Sequential     * Direct     * Indexed A file still if it is stored on a magnetic disk or CD-ROM disk may perhaps have a sequential file organiz

Define I/O and CPU Bursts   Applications typically to through cycle of CPU bursts and Input/output bursts. Since the CPU sits idle during I/O operations, efficiency is improved

What is process control block? Every process is represented in the OS by a process control block. It has many pieces of information associated with an exact process.

What is Multitasking? Multitasking provides power to users by offering them to run multiple applications at once. The applications are loaded into memory and appear to the user

Question: a) Each process is represented in the operating system by a process control block (PCB). The PCB contains many pieces of information associated with a specific proce

Processes and threads each have their place in multi-programming, generally to hide latency and to maximize CPU utilization. With the continuing spread of multi-core processors in

#questionThe Fibonacci sequence is the series of numbers 0,1,1,2,3,5,8,… Formally, it can be expressed as: fib0 = 0 fib1 = 1 fibn = fib n-1 + fib n-2 Write a C program u

Optimal page replacement An optimal page replacement algorithm has the least page fault rate of all algorithms. The algorithm states that put back the page that will not be us

Introduction of linux