Quantae is a comprehensive operating systems project spanning two phases, implementing CPU process scheduling algorithms and memory management for a simulated OS. The project demonstrates how a real operating system kernel manages process lifecycle, IPC, and virtual memory.
- Phase 1: Implement multiple CPU scheduling algorithms (RR, HPF, FCFS 2 CPUs) to compare performance metrics.
- Phase 2: Integrate memory management with the schedulerβintroducing page tables, memory requests, blocked queues, and memory-induced process blocking.
Quantae/
βββ phase1_code/ # Phase 1: CPU Scheduling Algorithms
β βββ schedulerRR.c # Round-Robin scheduler
β βββ schedulerHPF.c # Highest Priority First scheduler
β βββ schedulerCPU2.c # FCFS 2 CPUs scheduler
β βββ process_generator.c # Phase 1 driver for loading processes
β βββ process.c / process.h # Child process execution
β βββ queue.c / queue.h # Process queue data structure
β βββ clk.c # Simulated system clock
β βββ logger.c / logger.h # Event logging for analysis
β βββ test_generator.c # Random workload generator
β βββ process.h # PCB (Process Control Block) definition
β βββ headers.h # Shared constants and IPC keys
β βββ Makefile # Build configuration
β βββ scheduler.log # Simulation output log
β βββ scheduler.perf # Simulation performance metrics
β βββ scheduler2.log # Simulation output log (2nd CPU)
β βββ scheduler2.perf # Simulation performance metrics (2nd CPU)
β
βββ phase2_code/ # Phase 2: Memory Management Integration
β βββ scheduler.c # Enhanced scheduler with memory support
β βββ mmu.c / mmu.h # Memory Management Unit (page tables, requests)
β βββ process_generator.c # Phase 2 driver
β βββ clk.c # Simulated clock
β βββ process.c / process.h # Enhanced process with memory requests
β βββ queue.c / queue.h # Enhanced queue for blocked processes
β βββ logger.c / logger.h # Enhanced logging
β βββ headers.h # Shared definitions
β βββ test_generator.c # Random workload generator
β βββ requests_i.txt # Per-process memory request traces
β βββ processes.txt # Input process list (user-defined)
β βββ Makefile # Build configuration
β βββ memory.log # Simulation memory actions log
β
βββ README.md
βββ Final Test Cases.txt # Comprehensive test suite documentation
The first phase focuses on implementing and comparing different CPU scheduling strategies in a simulated environment.
| Algorithm | File | Description |
|---|---|---|
| Round-Robin (RR) | schedulerRR.c |
Time-sliced execution with fixed quantum; processes rotate in ready queue |
| Highest Priority First (HPF) | schedulerHPF.c |
Non-preemptive; always runs the highest-priority ready process |
| FCFS 2 CPUs | schedulerCPU2.c |
FCFS with dual CPUs; distributes processes across two independent queues with load balancing via work stealing to reduce imbalance and improve overall utilization. |
- Process Generator: Reads
processes.txtand sends processes to scheduler at their arrival times - Simulated Clock:
clk.cprovides a synchronized global time for all components - IPC Communication: Uses UNIX message queues and semaphores for inter-process communication
- Event Logging: Records all process state transitions (start, preemption, finish) with timestamps
- Performance Metrics: Computes turnaround time, weighted turnaround time, and CPU utilization
Phase 2 extends the scheduler with virtual memory management, introducing page tables, memory requests, and process blocking due to memory I/O.
| Component | File | Purpose |
|---|---|---|
| MMU | mmu.c / mmu.h |
Manages page tables, frame allocation, and memory request handling |
| Memory Requests | requests_*.txt |
Per-process traces of memory access patterns (read/write) |
| Blocked Queue | Enhanced scheduler | Manages processes waiting for memory operations to complete |
| Enhanced Scheduler | scheduler.c |
Coordinate CPU scheduling with memory request handling |
- Page Table Management: Each process gets allocated a page table frame upon start
- Memory Requests Handling: Processes issue memory read/write requests that may block execution
- Blocked Queue: Separate queue for processes waiting on memory I/O
- Simulated Page Faults: System models realistic memory access delays
- R-bit Clearing: Periodic clearing of reference bits (R-bits) based on a parameter K
- Process Arrival β Scheduler receives via message queue
- Memory Initialization β MMU allocates page table frame
- CPU Execution β RR scheduling with quantum-based preemption
- Memory Request β Process issues R/W at scheduled time
- Blocking β If memory busy, process moves to blocked queue
- Resumption β Process returns to ready queue when memory operation completes
- Completion β Process finishes when remaining time reaches zero
Main simulation driver:
- Parses
processes.txt - Validates process fields
- Creates IPC resources (message queue, semaphores)
- Forks clock and scheduler
- Sends processes to scheduler at arrival times
- Logs all events
Core scheduling logic with memory integration:
- Ready queue and blocked queue management
- RR quantum enforcement
- Process fork/exec and state transitions
- Calls to
mmu.cfor memory operations - Loads per-process memory request files (
requests_*.txt) - Processes memory requests and manages blocking
Memory Management Unit simulation:
- Initializes page tables for each process
- Loads memory request traces from per-process files
- Simulates page allocation and frame assignment
- Tracks memory operations and request completion
Simulated system clock shared across all processes:
- Uses signal-based time advancement
- Accessed via
getClk()for process synchronization - Initialized/destroyed by process generator
Child process behavior:
- Executes scheduled process logic
- Issues memory requests at scheduled relative times
- Communicates with scheduler via IPC
- Implements R-bit functionality for memory tracking
cd phase1_code
make build
./process_generator.outOr with a custom process file:
./process_generator.out custom_processes.txtcd phase2_code
make buildRun the simulation:
./process_generator.outOr with a custom process file:
./process_generator.out custom_processes.txt./test_generator.out
# Follow prompts to specify number of processes| Target | Action |
|---|---|
make build |
Compile all executables |
make clean |
Remove all .out binaries |
make all |
Clean and rebuild |
make run |
Execute process_generator.out |
Quantae β A two-phase OS simulation project exploring CPU scheduling and memory management.
