Em Andamento

Working with semaphores in Java

Answer the following:

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()

{

[url removed, login to view]();

[url removed, login to view]();

[url removed, login to view]();

[url removed, login to view]();

}

Vehicle()

{

while(True)

{

[url removed, login to view]();

[url removed, login to view]();

[url removed, login to view]();

Drive through habitat for some arbitrary amount of time;

[url removed, login to view]();

}

}

*NOTE:

There are n vistor tasks (threads) and m vehicle tasks (threads) that are created by some other section of code (assume there is an initialization routine that creates them). Thus, the pseudo code represents the visitor and vehicle routines that represent the threads. You are not coding this, but discussing the correctness of the pseudo code to solve the problem of coordinating n visitor threads to m vehicle threads. Classic semaphore notation includes the primitives of wait and signal (Java's acquire and release).

Habilidades: Java

Ver mais: up working, a true solution consists of a single, coding in java, random signal, problem in java, java issues, habitat, gopher, correctness, java notation, explain java code, java tasks, line mall, visitor vehicle semaphore, java semaphores, semaphore pseudo code solution, gopher gallery consists shopping mall cart ride covers, shopping mall system, threads java threads, java shopping system, semaphores, semaphore vehicleavailable vehicletaken vehiclefilled visitorreleased, java pseudo, vehicle java, acre

Acerca do Empregador:
( 4 comentários ) Pho, United States

ID do Projeto: #5088324

Premiar a:

it2051229

Hired by the Employer

$40 USD em 1 dia
(248 Avaliações)
6.4