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 modern operating systems, applications do not directly access the physical memory. Instead, they use so-called virtual memory, where each virtual address is translated to a phys

List out the advantages of windows 2000 file management. Permits detailed security for individual folders and files. Built-in granular compression capabilities

SCAN o Go from the outside to the inside servicing requests and after that back from the outside to the inside servicing requests. o Replicate this over and over. o Diminish

what is hashed page tables & explain of there work & figure

what is the need-to-know principle? why is it important for a protection system to adhere to this principle?

Q. In some systems a subdirectory is able to be read and written by an authorized user just as ordinary files can be. a. Explain the protection problems that could arise. b.

what is the meaning of co-operating process?

Q. Explain application of consumer behaviour? Consumer behaviour is described as the dynamic interaction of affect and cognition and behaviour and the environment by human bein

List five services provided by an operating system. Explain how each provides convenience to the users. Explain also in which cases it would be impossible for user-level programs t

Paging full question