A comprehensive RTOS simulator demonstrating interrupt-driven architecture for vehicle sensor management with priority-based task scheduling, bounded latency, and safe shared resource management.
pip install -r requirements.txtpython run.pyNavigate to: http://localhost:5000
โ
Priority-Based Preemption - Higher priority tasks interrupt lower ones
โ
Interrupt-Driven Architecture - Sensor events trigger ISRs and tasks
โ
Bounded Latency - Microsecond precision timing guarantees
โ
Deterministic Behavior - Predictable, repeatable execution
โ
Safe Resource Sharing - Mutex-protected shared data
โ
Complete Event Logging - Full event trail with timestamps
๐ฎ Sensor Event Simulator - Trigger 3 virtual sensors with different priorities
๐ Real-Time Monitoring - Live status of all system components
๐ System Statistics - Task counts, CPU usage, interrupt tracking
๐ Event Log - Real-time system events with export capability
Browser Dashboard (Web UI)
โ (HTTP API)
Flask Server (run.py)
โ
Interrupt Controller
โ
ISR Handlers
โ
RTOS Scheduler
โ
Sensor Tasks (Brake, Collision, Speed)
โ
Shared Resources (Protected)
โ
Event Logger
Real-Time_Vehicle_Sensor_Management_System/
โโโ run.py # Main Flask server โญ
โโโ requirements.txt # Python dependencies
โโโ README.md # This file
โโโ SYSTEM_DOCUMENTATION.md # Detailed documentation
โ
โโโ Core Components:
โโโ interrupt_controller.py # Virtual interrupt simulation
โโโ rtos_simulator.py # RTOS scheduler
โโโ logger.py # Event logging system
โโโ shared_resources.py # Shared resource protection
โโโ verifier.py # Real-time property verification
โ
โโโ tasks/ # Sensor task implementations
โ โโโ brake_task.py # Priority 7 (Highest)
โ โโโ collision_task.py # Priority 6 (High)
โ โโโ speed_task.py # Priority 5 (Medium)
โ
โโโ Web Interface:
โโโ templates/
โ โโโ dashboard.html # Web dashboard UI
โโโ static/
โ โโโ style.css # Dashboard styling
โ โโโ script.js # Dashboard interactivity
- Open http://localhost:5000 in your browser
- Click sensor buttons:
- ๐ Brake Sensor (Priority 7) - Safety critical
โ ๏ธ Collision Sensor (Priority 6) - High priority- โก Speed Sensor (Priority 5) - Medium priority
- ๐จ ALL SENSORS - Demonstrates priority scheduling (BrakeโCollisionโSpeed)
Sensor Status Cards - Real-time readings from each sensor
System Statistics - Active task, CPU usage, task states
Event Log - Real-time system events:
- Interrupt triggers
- ISR entry/exit
- Task start/preemption/end
- Export Log - Download event history as text file
- Clear Log - Reset event history
- Manual Refresh - Force update all data
| Endpoint | Method | Purpose |
|---|---|---|
/ |
GET | Dashboard UI |
/api/sensor-data |
GET | Current sensor readings |
/api/trigger-sensor/<name> |
POST | Trigger sensor interrupt |
/api/event-log |
GET | System event log |
/api/system-stats |
GET | RTOS statistics |
/health |
GET | System health check |
Higher priority tasks preempt lower priority ones in real-time.
Interrupts are processed in priority order with bounded latency.
Running tasks are interrupted when higher-priority events occur.
Same sequence of events produces identical results every time.
Shared resources protected with mutexes prevent race conditions.
| Metric | Value | Status |
|---|---|---|
| Interrupt Latency | <5 ฮผs | โ Bounded |
| Task Response Time | <10 ฮผs | โ Bounded |
| Brake Task WCET | 50 ฮผs | โ Guaranteed |
| Collision Task WCET | 40 ฮผs | โ Guaranteed |
| Speed Task WCET | 30 ฮผs | โ Guaranteed |
| Priority Inversion | Prevented | โ Safe |
| Deadlock Risk | None | โ Safe |
- Click "Speed Sensor" to start SpeedTask
- Click "Brake Sensor" to preempt
- Observe in event log: "TASK_PREEMPT: SpeedTask preempted by BrakeTask"
- Rapidly click all three sensor buttons
- Observe interrupts queued by priority
- Higher priority interrupts process first
- Trigger a sensor
- Check event log timestamps
- Measure time between interrupt and ISR entry (<5ฮผs)
- Click "ALL SENSORS" button
- Observe execution order: Brake(P7) โ Collision(P6) โ Speed(P5)
- Note that sensors execute in priority order regardless of trigger sequence
- Perform same sequence twice
- Export logs from both runs
- Verify identical ordering and timing
Quick handler that:
- Logs interrupt entry
- Signals corresponding task
- Returns immediately (defers work to task)
Longer processing routine that:
- Executes after ISR signals it
- Can be preempted by higher priority tasks
- Accesses shared resources safely
Determines task execution order:
- 7 = Brake (Safety critical)
- 6 = Collision (High priority)
- 5 = Speed (Medium priority)
When higher-priority task becomes ready, it interrupts current task.
- [TIMESTAMP] - Microsecond precision
- EVENT_TYPE - Type of event (INTERRUPT, ISR, TASK, etc.)
- DETAILS - Specific information about event
- Active Task - Currently running task
- CPU Usage - Percentage of CPU utilized
- Task States - Count of READY, RUNNING, BLOCKED tasks
- Total Interrupts - Cumulative interrupt count
Port 5000 already in use?
# Find and kill the process
netstat -ano | findstr :5000
taskkill /PID <PID> /FDashboard not updating?
- Check browser console (F12)
- Verify Flask server is running
- Try refreshing the page
- Check network tab for failed requests
Events not appearing?
- Ensure you've clicked at least one sensor button
- Check that RTOS scheduler is running in background
- Verify interrupt controller is initialized
For detailed technical documentation, see:
- SYSTEM_DOCUMENTATION.md - Complete system architecture and specifications
For production deployment:
# Install production WSGI server
pip install gunicorn
# Run with Gunicorn
gunicorn -w 4 -b 0.0.0.0:5000 run:app- Python 3.8+
- Flask 2.0+
- Threading support
- Modern web browser
See requirements.txt for complete list.
After working with this system, you'll understand:
โ How interrupts are handled in real-time systems
โ Priority-based task scheduling
โ Task preemption mechanisms
โ Interrupt service routine design
โ Shared resource protection
โ Bounded latency guarantees
โ Deterministic behavior in concurrent systems
- Additional sensor types
- Deadline-based scheduling
- Performance analysis tools
- Timeline visualization
- Hardware sensor integration
- Load testing framework