A comprehensive operating system simulator implementing core OS functionalities including process scheduling, memory management, and inter-process communication.
- Multiple Scheduling Algorithms:
- Shortest Remaining Time Next (SRTN) - Preemptive shortest job first
- Round Robin (RR) - Time-sliced fair scheduling
- Non-preemptive Highest Priority First (HPF) - Priority-based scheduling (0 = highest, 10 = lowest)
- Real-time process state tracking and visualization
- Comprehensive performance metrics and statistics
- Total Memory: 1024 bytes with buddy allocation algorithm
- Process Size Limit: Up to 256 bytes per process
- Tree-based memory allocation with efficient splitting and merging
- Automatic fragmentation reduction
- Dynamic memory allocation/deallocation simulation with detailed logging
- Shared Memory: High-speed data exchange between Process Generator and Scheduler
- Message Queues: Reliable, structured communication for process coordination
- Clock Synchronization: All components synchronized through shared clock process
- POSIX IPC mechanisms for safe concurrent access and resource cleanup
The simulator provides detailed analytics including:
- CPU Utilization - Percentage of time CPU is actively executing processes
- Average Weighted Turnaround Time (WTA) - Time from arrival to completion weighted by runtime
- Average Waiting Time - Time processes spend waiting in ready queue
- Standard Deviation of WTA - Measure of scheduling consistency
- Memory Allocation Efficiency - Fragmentation analysis and allocation success rates
- Unix/Linux environment
- GCC compiler
- Make utility
- POSIX IPC support
# Clone the repository
git clone https://github.com/cmp-2060-sp25/kernel-sim-kernix.git
cd kernel-sim-kernix
# Compile the project
make
# Run the simulator
./os-sim
# Compile individual components
gcc -o process_generator process_generator.c
gcc -o scheduler scheduler.c
gcc -o process process.c
gcc -o clk clk.c
# Run the main simulator
./os-sim
# Run the simulator (will prompt for scheduling algorithm)
./os-sim
# Available scheduling algorithms:
# 1. HPF (Non-preemptive Highest Priority First)
# 2. SRTN (Shortest Remaining Time Next)
# 3. RR (Round Robin) - requires time quantum parameter
Create a processes.txt
file with the following format:
# id arrival_time runtime priority memsize
1 1 6 5 200
2 3 3 3 170
4 4 8 2 256
Field Descriptions:
id
: Process identifierarrival_time
: When process arrives (integer seconds)runtime
: CPU burst time requiredpriority
: Priority level (0 = highest, 10 = lowest)memsize
: Memory required in bytes (≤ 256)
File | Description |
---|---|
scheduler.log |
Process state changes (started/stopped/resumed/finished) |
scheduler.perf |
CPU utilization, WTA, waiting time, and standard deviation |
memory.log |
Memory allocation/deallocation events with addresses |
At time 1 process 1 started arr 1 total 6 remain 6 wait 0
At time 3 process 1 stopped arr 1 total 6 remain 4 wait 0
At time 3 process 2 started arr 3 total 3 remain 3 wait 0
At time 6 process 2 finished arr 3 total 3 remain 0 wait 0 TA 3 WTA 1.00
At time 6 process 1 resumed arr 1 total 6 remain 4 wait 3
At time 10 process 1 finished arr 1 total 6 remain 0 wait 3 TA 9 WTA 1.50
=== PERFORMANCE STATISTICS ===
CPU utilization = 90%
Avg WTA = 1.25
Avg Waiting = 1.5
Std WTA = 0.35
┌─────────────────┐
│ Clock │
│ (Time Sync) │
└─────────┬───────┘
│
┌─────────▼───────┐
│ │
┌──────────▼──────────┐ │ ┌─────────────────┐
│ Process Generator │ │ │ Scheduler │
│ • Creates processes│◄────┼────►│ (HPF/SRTN/RR) │
│ • Manages memory │ │ │ • Process mgmt │
│ • Sends to sched │ │ │ • PCB tracking │
└──────────┬──────────┘ │ └─────────┬───────┘
│ │ │
▼ │ ▼
┌─────────────────┐ │ ┌─────────────────┐
│ Buddy System │ │ │ Process 1 │
│ (1024 bytes) │ │ │ Process 2 │
│ Memory Alloc │ │ │ Process N │
└─────────────────┘ │ └─────────────────┘
│
┌────────────────┘
▼
┌─────────────────┐
│ IPC │
│ • Shared Memory │
│ • Message Queue │
└─────────────────┘
System Flow:
- Process Generator reads input file and manages memory allocation via Buddy System
- Clock Process provides time synchronization for all components
- Scheduler receives process information via IPC and manages scheduling
- Processes execute and communicate completion back to scheduler
- Memory is freed by Process Generator when processes terminate
# Compile test generator
gcc -o test_generator test_generator.c
# Generate test cases
./test_generator 100 # Generate 100 random processes
- Algorithm Comparison: Compare HPF vs SRTN vs RR performance
- Priority Testing: Verify priority handling (0 = highest to 10 = lowest)
- Memory Pressure: Test buddy system with various allocation patterns
- Concurrent Arrivals: Handle multiple processes arriving simultaneously
- 📖 Phase 1 Report - Process Scheduling & IPC Implementation
- 📖 Phase 2 Report - Memory Management & Buddy System
This project is licensed under the MIT License - see the LICENSE file for details.
Avatar | Name |
---|---|
omar gamal | |
Abdallah Ayman | |
Mohamed Abdelaziem | |
Omar Hassan |
⭐ Star this repository if you found it helpful! ⭐