A small Java program that simulates classic CPU scheduling (FCFS, Priority), prints a text Gantt chart, and calculates WT/TAT/CPU Utilization. It also includes Memory Allocation (First/Best/Worst Fit) and Paging (FIFO) demos.
- Scheduling: FCFS, Priority (non-preemptive; lower number = higher priority)
- Metrics: Waiting Time, Turnaround Time, Averages, CPU Utilization
- Gantt Chart: Text-based like
| P1 | P2 | ...with times underneath - Memory: First-Fit, Best-Fit, Worst-Fit (fixed blocks typed by user)
- Paging: FIFO page replacement (Belady anomaly demo ready)
# compile
javac OS_Simulation.java
# run (menu)
java OS_SimulationWhen asked for the input file, press Enter to use processes.txt at the project root, or type a path.
# FCFS with baseline set
copy data/processes_baseline.txt processes.txt # Windows (PowerShell: cp)
cp data/processes_baseline.txt processes.txt # macOS/Linux
java OS_Simulation
# choose: 1
# Priority (non-preemptive)
java OS_Simulation
# choose: 2
# Memory (try first/best/worst)
cp data/processes_mem_diff.txt processes.txt
java OS_Simulation
# choose: 3
# blocks: 60,70,100,25
# method: first (or best / worst)
# Paging (Belady refs: 3 frames vs 4)
cp data/references_belady.txt references.txt
java OS_Simulation
# choose: 4
# frames: 3 -> faults ~ 9
# frames: 4 -> faults ~ 10 (worse with more frames)If IntelliJ can't find
processes.txt, set Run → Edit Configurations → Working directory =$ProjectFileDir$ .
.
├── OS_Simulation.java # single-file Java program (entrypoint: main)
├── processes.txt # default input (you can swap from /data)
├── references.txt # default paging refs (you can swap from /data)
├── data/
│ ├── processes_baseline.txt
│ ├── processes_idle_gaps.txt
│ ├── processes_ties.txt
│ ├── processes_no_mem_column.txt
│ ├── processes_mem_diff.txt
│ ├── references_fifo1.txt
│ └── references_belady.txt
└── docs/
└── report_student.md