This project demonstrates core Operating Systems concepts through two practical modules:
- A real-time, multi-threaded Resource Monitor in C that reads Linux
/procdata, logs metrics, and publishes summaries via POSIX message queues. - A Process Scheduler Simulator in C++ implementing classic algorithms with metrics and Gantt chart output.
It’s ideal for students and practitioners who want a hands-on understanding of threading, synchronization, IPC, and CPU scheduling.
-
✅ C-based Resource Monitor
- CPU, Memory, Disk I/O, and Network monitoring (via
/proc) - Multi-threaded producers + synchronized logger (producer–consumer pattern)
- Alerts when CPU/MEM exceed thresholds
- Periodic summaries via POSIX message queues (IPC)
- Graceful shutdown (Ctrl+C)
- CPU, Memory, Disk I/O, and Network monitoring (via
-
✅ C++ Scheduler Simulator (STL-based)
- Algorithms: FCFS, SJF, Round Robin (q=2), Priority, Multilevel Queue
- Computes Waiting Time, Turnaround Time, Throughput
- Prints Gantt chart slices for visualization
- Appends results to
data/reports/scheduler_report.txt
-
✅ IPC Consumer
- Reads and prints live summaries from the POSIX message queue
-
✅ Automation Scripts
cleanup_logs.sh— cleanup and retention for logshealth_check.sh— simple CPU/MEM threshold alertinggenerate_report.sh— collates recent logs and scheduler report
-
Threaded Monitoring (C)
- One thread each for CPU, Memory, Disk, Network → enqueues metrics
- Logger thread dequeues metrics, writes to
data/logs/resource_log.txt, and raises alerts - Every few seconds, a summary (e.g.,
CPU=xx.x% MEM=yy.y%) is sent to a POSIX message queue (default:/sysmon_queue)
-
Scheduler Algorithms (C++)
- Reads processes from CSV:
PID,Arrival,Burst,Priority - Runs FCFS, SJF, RR(q=2), Priority, Multilevel Queue
- Produces per-process waiting/turnaround, averages, throughput, and Gantt chart slices
- Reads processes from CSV:
-
IPC Messaging
- Separate consumer reads summaries from the message queue and prints them to stdout
- Linux or Windows Subsystem for Linux (WSL)
- GCC, G++, Make, Bash
- Access to Linux
/procfilesystem and POSIX message queues
Note: On Windows, use WSL and run commands from a WSL terminal.
Clone the repository and build all targets:
git clone https://github.com/<your-username>/SystemResourceMonitor.git
cd SystemResourceMonitor
make allIf using WSL and your project is in a Windows folder, use:
cd "/path/to/SystemResourceMonitor"
make allIf needed, install build tools (Ubuntu):
sudo apt update && sudo apt install -y build-essential
🚦 Quick Start: All-in-One
make all && make run_monitorBuilds everything and starts the resource monitor. Press Ctrl+C to stop.
Resource Monitor started. Press Ctrl+C to stop. Logging to data/logs/resource_log.txt Sending summaries to POSIX mq /sysmon_queue (if available)
🖥️ Resource Monitor (C)
make run_monitorMonitors CPU, memory, disk, and network. Logs to data/logs/resource_log.txt.
1697654321000,CPU,42.35 1697654321500,MEM,61.20 1697654322000,DISK,128,64 1697654322500,NET,4096,2048 1697654323000,ALERT,CPU_HIGH,91.75
📡 IPC Consumer (POSIX MQ)
./bin/ipc_consumerShows live summaries from the message queue.
[Summary] CPU=37.4% MEM=58.2% [Summary] CPU=41.9% MEM=60.1%
📊 Scheduler Simulator (C++)
./bin/scheduler data/processes.csvRuns all algorithms and prints Gantt chart. Appends to data/reports/scheduler_report.txt.
Algorithm: FCFS PID Waiting Turnaround 1 0 5 2 4 6 3 7 15 Avg Waiting: 3.7, Avg Turnaround: 8.7, Throughput: 0.3 Gantt: |P1(0-5)|P2(5-8)|P3(8-16)| end=16
📝 Generate a consolidated report
bash scripts/generate_report.shThe combined report is saved to data/reports/final_summary.txt.
=== System Resource Monitor Summary === ... (last 50 log lines) ... === Scheduler Latest Report === ... (last 50 scheduler report lines) ...
🕹️ (Optional) Interactive Menu
./bin/menuText-based menu to run all modules and scripts.
SystemResourceMonitor/
├── src/
│ ├── resource_monitor.c # C monitor (threads, /proc, IPC, signals)
│ ├── ipc_consumer.c # POSIX mqueue summaries reader
│ ├── scheduler_simulator.cpp # C++ scheduling simulator
│ └── main.cpp # minimal interactive menu
├── include/
│ ├── monitor.h
│ └── scheduler.h
├── scripts/
│ ├── cleanup_logs.sh
│ ├── health_check.sh
│ └── generate_report.sh
├── data/
│ ├── processes.csv # sample scheduler input
│ ├── logs/
│ │ └── resource_log.txt # generated at runtime
│ └── reports/
│ └── scheduler_report.txt # generated at runtime
├── bin/ # built executables
├── Makefile
└── README.md
- Gantt chart (console):
Algorithm: FCFS
PID Waiting Turnaround
1 0 5
2 4 6
3 7 15
Avg Waiting: 3.7, Avg Turnaround: 8.7, Throughput: 0.3
Gantt: |P1(0-5)|P2(5-8)|P3(8-16)| end=16
- Resource log snippet (
data/logs/resource_log.txt):
1697654321000,CPU,42.35
1697654321500,MEM,61.20
1697654322000,DISK,128,64
1697654322500,NET,4096,2048
1697654323000,ALERT,CPU_HIGH,91.75
- IPC consumer (summaries):
[Summary] CPU=37.4% MEM=58.2%
[Summary] CPU=41.9% MEM=60.1%
- Shared Memory or Pipes as an additional IPC demo
- Cron integration for
health_check.sh - Live statistics in the interactive menu (e.g., stream last summary)
- Configurable thresholds and sampling intervals via a config file
Contributions are welcome! Feel free to open issues or submit PRs:
- Add new scheduling algorithms or visualizations
- Improve error handling, parsing, or portability
- Expand documentation and examples
Please follow conventional commit messages and include a brief description of changes.
This project is licensed under the MIT License – see the LICENSE file for details.
- Maulishka Srivastava @Maulishka04
- Thanks to the Linux
/procdocumentation and the C/C++ standard libraries