A high-fidelity Operating System simulator that models:
CPU scheduling (Preemptive Priority + Round Robin)
Resource allocation & contention
Deadlock detection and recovery
Starvation prevention via aging
Built as an interactive CLI system , allowing users to step through execution tick by tick and observe real OS behavior in real time.
Interactive CLI Experience
[Time = 42]
Running: P2
Ready: P0, P3
Waiting: P1 (R2)
IO Queue: P4 (3 ticks)
Command โ [Enter = step | a = auto-run]
โฑ๏ธ Step-by-step execution (Enter)
โก Auto-run mode (a)
๐ Live queue visualization
๐จ Pink-themed ANSI interface
graph LR
A[NEW] --> B[READY]
B --> C[RUNNING]
C -->|Preempt| B
C -->|Request Resource| D[WAITING]
C -->|IO Burst| E[IO]
D --> B
E --> B
C --> F[TERMINATED]
Loading
๐ง Hybrid Scheduling Strategy
Priority Scheduling (Preemptive)
+
Round Robin (Same Priority)
+
Aging Mechanism
๐ฏ Higher priority always wins
๐ Same priority โ Round Robin (Quantum = 5)
โจ Aging every 10 ticks โ prevents starvation
Resource Allocation Graph (Banker-style reduction)
Runs every clock tick
1. Detect circular wait
2. Select victim (lowest priority)
3. Terminate process
4. Release all resources
5. Resume system safely
Type
Example
Description
CPU
5
Execute for 5 time units
Request
R[1,2]
Request 2 units of Resource 1
Free
F[1,2]
Release resources
IO
IO{3}
Perform IO for 3 ticks
๐งช Simulation Scenarios
P0 holds R1 โ needs R2
P1 holds R2 โ needs R1
๐ฅ Deadlock detected!
๐ Killing victim: P1
๐ Resources released
๐ข Starvation Prevention (Aging)
Initial Priority: P0 = 20 (very low)
โจ Aging Triggered
โ P0 priority: 20 โ 19 โ 18 ...
โ
Eventually scheduled
[T=15]
Running โ P1
Ready โ P0, P2
Waiting โ P3 (R1 unavailable)
โจ Aging: P0 priority improved โ 4
----------------------------------
[T=16]
๐จ Deadlock Detected!
๐ Terminating P3
๐ Resources Released
OS-Scheduler-Pink/
โโโ prj.py # Core simulation engine
โโโ scenario1.txt # Deadlock case
โโโ scenario2.txt # Aging case
โโโ scenario3.txt # Complex deadlock chain
โโโ scenario4.txt # Crciular wait
โโโ README.md
python prj.py scenario1.txt
Key
Action
Enter
Step forward
a
Auto-run
Ctrl+C
Stop execution
๐ Why This Project Stands Out
Simulates real OS concepts , not simplified models
Combines 3 scheduling techniques in one system
Implements actual deadlock recovery logic
Fully interactive (rare for OS projects)
Designed with clear visualization in mind
Course
ENCS3390 โ Operating Systems
University
Birzeit University ๐ต๐ธ
Student
Shatha Abualrob
Semester
Fall 2025/2026