1. Practice using threads.
2. Practice designing and implementing simulations.
Each of the following projects involves the use of threads in a real-time simulation. Your instructor will tell you which of them you are to do, and will provide any input files to be used to test your program.
13.1. Modify the simulation from the lab exercise so that each Teller has its own line. Add input statements to the simulation so that the minimum and maximum time between customers and the minimum and maximum time for a customer transaction are entered by the user at the start of the simulation.
13.2. Write a simulation that determines the average time for all contestants in a game of tag to be caught. Model the problem with a 2D grid. Each spot on the grid is a possible position. Contestants can move in any of the four cardinal directions. One contestant starts out as the chaser. All other contestants are evaders. If a chaser and an evade end up on the same grid point, the evader becomes a chaser too. Contestants should move in a random direction at given intervals.
Extra credit: Create different classes of contestants. Possibilities include: smart chasers which will move towards an evader that is close to it, smart evaders who move away from any chaser that is close, and faster runners that move more often.
13.3. Write a simulation that determines the average wait time at a traffic light. Cars arrive at the traffic light in any one of the four directions. If the light is green, the cars will line up behind any cars traveling in that direction which have not passed through the intersection. If the light is yellow or red, the cars will line up and wait. When the light turns green, the waiting cars will travel through the intersection one at a time every 3 seconds.
13.4. Write a simulation that determines the average time to handle a hard disk request. Information on a disk drive is stored in circular tracks. Requests for information will come to the disk drive at random intervals. There is a head that moves over the tracks and retrieves the information. To move the head from one track to the adjacent track will take 100 milliseconds. To access the information once the head is at the correct track takes 20 milliseconds. Implement two policies for handling disk requests.
Turn In: A hard copy of this grade sheet, attached to hard copies of
Don't forget to clean up your directory when you are all finished...
Back to the Lab Table of Contents
Back to the Lab Exercise
Back to the Table of Contents
Back to the Introduction