A multi-threaded traffic intersection simulation implemented in C++ to demonstrate fundamental Operating Systems concepts such as process management, synchronization, inter-process communication, and priority scheduling.
This project simulates a traffic control system with two intersections (F10 and F11). Vehicles of different types are generated concurrently and must safely pass through intersections while respecting traffic light phases, parking limits, and emergency vehicle priority.
- Two independent intersections (F10 & F11)
- Multiple vehicle types including emergency vehicles
- Priority-based scheduling for ambulances and fire trucks
- Traffic light phases (North–South / East–West)
- Parking system with limited capacity
- Thread-safe shared resource management
- Real-time terminal output and final statistics
- Multithreading using POSIX threads (
pthread) - Synchronization with mutexes, semaphores, and condition variables
- Process creation using
fork() - Inter-process communication using pipes
- Priority scheduling and resource management
g++ -pthread traffic-intersection-simulation.cpp -o traffic_sim
./traffic_simPress Ctrl+C to terminate the simulation safely.
Simulation parameters such as vehicle count, parking capacity, and traffic light duration can be modified at the top of
traffic-intersection-simulation.cpp.
traffic-intersection-simulation.cpp– main source fileREADME.mdLICENSE