Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Description: in this project, you will implement an intelligent traffic light system where cars anive at a one-way only tunnel. Your program should enforce the

image text in transcribed

Description: in this project, you will implement an intelligent traffic light system where cars anive at a "one-way only" tunnel. Your program should enforce the requirement that "only at most N cars in one direction can go through the tunnel at a time". The goal of the project is to leam multi-threading with bcks and condition variables. For implementation, you need to have variables for traffic lights on both North and South directions. Lights can be RED or GREEN only. If the light turns RED, m car should attempt to enter the tunnel. Otherwise, N cars should be allowed to enter and leave the tunnel You may either have one thread per car, in this case, N threads need to be woken up when the light turns GREEN. Or you may have one thread per direction and then manage to make N cars leave the tunnel in a sequence. Cars should arrive at a random time with an average interval of 60 seconds. To achieve this, you may do random-120, where the random number is within (0,1). Or you can do rand(%121. It should serve the same purpose. Please take account of the time for cars to leave the turnel, e.g., 60 seconds, as well as the time for a car to start and follow another car, e.g., 5 seconds. Such time can be implemented through a sleep function. Your program should calculate the total time taken for M cars in both directions together to pass the tunnel Your program should display the following events on screen: Thread creation When light changes for one directions Periodic print out of time taken so far There are two parameters to pass from the command line: Mand N Testing: Your program should run for Mcars until all cars pass the intersection. . . 1/2 30/12/2020 Project Cygwin compilation: "g++ -std=c++11 sample.cpp - pthread" Project Report: a max of 2-page brief description of the results (total time) on different combination of (M, N). You should briefly justify the result based on your observation and analysis. Submission: One zip file containing the following should be submitted: All source code Project report (2-page max) Link of a video demonstrating the execution of your code with the following: Show your code (10 seconds still screen) Compilation of your code Executing of your code f your code does not work, explain in the above video. . . o

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Reliability Engineering Designing And Operating Resilient Database Systems

Authors: Laine Campbell, Charity Majors

1st Edition

978-1491925942

More Books

Students also viewed these Databases questions