Note that the work that you turn in for this assignment must represent your individual effort. You are welcome to help your fellow students to understand the material of the course and the meaning of the assignment questions, however, the answer that you submit must be created by you alone. Assignments will be assessed on your efforts and approach you are using for particular solution.
1 Deadlock Detection
Consider an uncontrolled traffic intersection problem found in area where traffic is increasing day by day and new traffic system needs to be designed on intersection based on standard North America intersection protocol. You are required to simulate the intersection signalling controller solution and submit in a presentable form. For instance, see the Figure 1 where four cars reaching traffic intersection are deadlocked. You are encouraged to avoid this deadlock with your solution in any preferred programming language. Follow the given protocol:
Figure 1: Deadlocked intersection with four vehicles
- All roads (A, B, C, and, D) have two lanes giving each vehicle three ways(right, left, and, straight) on intersection to proceed.
- When vehicle Facing GREEN light:
- Vehicle can proceed two ways, i.e. right and straight
- For left tern driver must see there is no vehicle coming from other sides. If there is no vehicle take left turn or if there is one or more let them proceed first, before it take the turn.
- When vehicle Facing RED:
- For right tern vehicle must stop for 3 seconds and if no vehicle is coming from left, driver can take right. If there is one, let it proceed and wait for 3 seconds again watching if another vehicle is coming, if not; take right turn otherwise remain stopped and repeat the same process.
- At once both side must not have same signal light ON. If one is RED, second must be GREEN and vice versa.
- Of course, you need to give considerable transition period (for instance 2 seconds) from RED to GREEN. Use YELLOW light during the transition period.
- No need to consider Pedestrian, for the purpose of simulation.
- For this assignment you are required to simulation three vehicles on road Ag. (av1,av2,av3),two vehicles on B e.g. (bv1,bv2), one vehicle on C e.g. (cv1), and one on D e.g. (dv1). Your simulation should start with the described number of vehicles on each road and clearly output the status of each vehicle moving and going forward towards any of three sides but end of simulation all the vehicles should leave the intersection without any collision. You will randomly choose the direction for vehicles on the intersection in three direction: straight, left or right. You cannot choose the reverse direction. Record the reasonable turnaround time for the complete scenario proving deadlock free implementation.
- Change the number of vehicles of your simulation and determine the point where human error can cause a collision i.e. when driver takes right turn on RED light and did not stop for 3 seconds. Hint:use exception classes in your preferred programming language