Skip to content

fegzycole/Concurrent-Traffic-Simulation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Concurrent Traffic Simulation

A multithreaded traffic simulation that demonstrates concurrent programming principles using C++. Vehicles navigate through intersections controlled by traffic lights, with thread-safe communication implemented using mutexes, locks, and message queues.

Features

  • Real-time traffic simulation with multiple vehicles
  • Thread-safe traffic light system with random cycle durations (4-6 seconds)
  • Concurrent vehicle movement and intersection management
  • Visual representation using OpenCV
  • Message queue-based communication between components

Dependencies

Build Instructions

  1. Clone this repo.
  2. Make a build directory in the top level directory: mkdir build && cd build
  3. Compile: cmake .. && make
  4. Run it: ./traffic_simulation

Architecture

The simulation consists of several key components:

  • TrafficLight: Manages traffic light phases (red/green) with random cycle durations
  • MessageQueue: Thread-safe communication between traffic lights and vehicles
  • Intersection: Coordinates vehicle entry and traffic light control
  • Vehicle: Simulates vehicle movement and intersection navigation
  • Graphics: Renders the simulation using OpenCV

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors