Vehicle tasks using semaphores, 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, it allows the single passenger to climb aboard and drives 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. 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/15/2013 6:34:24 AM | Location : United States







Related Discussions:- Vehicle tasks using semaphores, Assignment Help, Ask Question on Vehicle tasks using semaphores, Get Answer, Expert's Help, Vehicle tasks using semaphores Discussions

Write discussion on Vehicle tasks using semaphores
Your posts are moderated
Related Questions
In this exercise we are going to use  pthread()to simulate the dynamics between a warehouse, factory and retail. The factory produces product by using parts supplied by the warehou

Define the WindowsNT WindowsNT provides a two-level approach to resource management: process and thread. The process is the uppermost level and contains most of the application

Question: OS Installation / File system a) Why is NTFS portioning preferred over FAT16 or FAT32 when security is of primary concern? b) State a situation or an application w


Q.  What kind of operating system is Windows XP? Describe two of its major features. Answer: A 32 or 64 bit pre-emptive multitasking operating system supporting multiple use

time-stamping It is a method proposed by Lamport, used to sequencing events in a distributed machine without the use of clocks. This process is intended to order events consis

Now let's implement bounded producer-consumer with semaphores, a Coke machine which is initially empty: semaphore sem_mutex = 1 // binary semaphore for mutual exclusion, 1==unlo

What is a thread? A thread or else called a lightweight process (LWP) is a basic unit of CPU utilization, it comprises of a thread id, a program counter, a register set and a s

advantages and disadvantages of monolithic and layered approach