Encerrado

elevator controller

**This homework must done by Augest 1st (Friday), 2003 before 11:00pm

**

You have been hired by the university to build a controller for an elevator in the 10 storied administration building, using semaphores or condition variables. The elevator is represented as a thread. Each person boarding or leaving the elevator is also represented by a thread. In addition to the elevator manager, you would need to implement the methods called by the arriving person. e.g. the method “ArrivingGoingFromTo(int atFloor, int toFloor)?? should wake up the elevator, tell it which floor to go to. The elevator is fast but it is not instantaneous, it takes only 100 ticks to go from one floor to the adjacent one. For simplicity, you can assume there is only one elevator and it holds arbitrary number of people. You can even assume that there is only one person entering the elevator at a floor at a time.

You have to come up with a way of storing the requests in the elevator manager, e.g. if a person is accessing the elevator at the 3rd floor and some body is trying to get access from the 5th floor then latter person has to wait before he could place his request. In other words he has to be put in a queue.

Also if the elevator is going upwards all the request for the destinations downwards will should not be accepted until it starts its downward motion and vice versa.

**The assignment has to be done in Java.**

## Deliverables

**This homework must done by Augest 1st (Friday), 2003 before 11:00pm

**

You have been hired by the university to build a controller for an elevator in the 10 storied administration building, using semaphores or condition variables. The elevator is represented as a thread. Each person boarding or leaving the elevator is also represented by a thread. In addition to the elevator manager, you would need to implement the methods called by the arriving person. e.g. the method “ArrivingGoingFromTo(int atFloor, int toFloor)?? should wake up the elevator, tell it which floor to go to. The elevator is fast but it is not instantaneous, it takes only 100 ticks to go from one floor to the adjacent one. For simplicity, you can assume there is only one elevator and it holds arbitrary number of people. You can even assume that there is only one person entering the elevator at a floor at a time.

You have to come up with a way of storing the requests in the elevator manager, e.g. if a person is accessing the elevator at the 3rd floor and some body is trying to get access from the 5th floor then latter person has to wait before he could place his request. In other words he has to be put in a queue.

Also if the elevator is going upwards all the request for the destinations downwards will should not be accepted until it starts its downward motion and vice versa.

**The assignment has to be done in Java.**

**Hint:** The following are just the suggestions as was also discussed in the class. You are free to follow any approach as long as it meets the specifications.

Import the package thread, with “**import .java.lang.***??.

The program will have two major classes “elevator?? and “person?? both of which will extend the Java “thread?? class. You can also use Holub’s package (whose website was mentioned in the class), which you can download along with its help files from the website [url removed, login to view]

In order to make sure that only one instance of “person?? enters the request to the elevator at a time, the keyword “synchronized?? can be used, which makes sure only one instance of the thread, piece of code or function can run at a time. “wait?? and “notify?? constructs may also be used for this purpose.

In order to simulate the 100 ticks between the two consecutive floors, you can use the “alarm?? (mentioned in the class) from Holub’s package. The code for the alarm can be found in the following directory of the package (/src/com/holub/asynch/[url removed, login to view]) However, to keep things simple if you wish you can also do so using a “wait (100)?? construct. You can refer to the website [url removed, login to view] for details of how to use “wait?? for this purpose.

You can refer to the website [url removed, login to view] /tutorial/essential/threads/[url removed, login to view] and [url removed, login to view] for all sorts of help related to java threads.

In order to compile a java code on a unix terminal, you first have to run the java compiler with “**javac <filename>**“ and after it gets compiled execute it with “**java <filename(executable)>**??.

Please take a look at [url removed, login to view] for help with general java issues.

**Testing:**

Instantiate 10 threads of type “person?? and each thread should request the elevator only once.

**Input file and:**

There is an input file supplied. It will be named **[url removed, login to view]**. It will have the following format. The first line will denote the number for floors, i.e. 10. Then in the subsequent lines, the first number denotes the ID or identification of the person, i.e. the thread ID, second number denotes the time (rather time stamp, e.g. the first request is taken at time 0) the request was made, the third number denotes the starting floor and the fourth number denotes the destination floor. There will as many lines as the number of requests.

**Note:** You can assume 100 ticks is equivalent to your 1 unit of time (discussed above).

**Output file:**

The format for the output file should be something like following.

“**Person (Thread ID) # makes request at time # starting at floor # with the destination floor #.**??

There should be as many lines printed as are the number of requests. You should also generate an output file **[url removed, login to view]** to store your output.

**Note: You must assume that you the starting time for the first request is 0. Do not use any built in java method for keeping track of timing.**

Habilidades: Engenharia, Java, MySQL, PHP, Arquitetura de software, Teste de Software

Ver mais: tutorial words, tutorial building website, src program, src format file, php unit testing software, number tutorial, index tutorial, import administration, program website java, build website tutorial, go tutorial, general floor, fourth floor, building website tutorial, software unit testing, time compiler, program manager download, php compiler, make website free fast, get download manager, download free java software, motion track, java thread, java issues, go lang

Acerca do Empregador:
( 3 comentários ) United States

ID do Projeto: #2958646

4 freelancers estão ofertando em média $40 para este trabalho

exceptionalcoder

See private message.

$85 USD in 2 dias
(8 Comentários)
4.0
zzzjim

See private message.

$25.5 USD in 2 dias
(4 Comentários)
1.3
verasoft

See private message.

$25.5 USD in 2 dias
(2 Comentários)
0.7
techw

See private message.

$25.5 USD in 2 dias
(0 Comentários)
0.0