This project is a Python-based simulation of CPU scheduling behavior across multiple processor configurations and scheduling policies. It is designed to model and compare the performance of common scheduling algorithms such as FIFO, Shortest Job First (SJF), and Round Robin (RR) under different system assumptions.
The simulator is split and organized into different components that separate process modeling, processor behavior, queue management, scheduling logic, and statistics.
The goal of this project is to simulate how processes are scheduled on a set of processors and to compare metrics such as:
- Average turnaround time
- Average waiting time
- Average response time
- Completed processes
The project also supports different simulation modes that represent the four parts of the assignment:
- Part 1: homogeneous processors
- All processors operate with identical speed and memory capabilities.
- Part 2: heterogeneous processor speeds
- Processors are assigned varying speed while memory remains uniform.
- Part 3: heterogeneous processors with memory constraints
- Processors are assigned varying speeds and distinct memory capacity limits.
- Part 4: limited lookahead / online-style scheduling
- The global process set is hidden, scheduling decisions are now restricted to a lookahead window of 5 based on arrival time.
This is the entry point of the program. It initializes the simulation scenarios, creates processor sets for each part, and runs the simulator for the selected scheduling algorithms.
Contains global configuration values used throughout the simulation, including:
- time quantum for Round Robin
- lookahead window size
- algorithm names
- other project-wide constants
Defines the Process object, which represents a single job in the system. Each process stores:
- process ID
- CPU cycles required
- memory needed
- arrival time
- execution state and timing metrics
Defines the Processor class. A processor models a CPU core and contains:
- processor name
- speed
- memory capacity
- current assigned process
- execution state
This component is responsible for checking whether a process can be assigned to that processor and for executing work over time.
Implements the ready queue used by the simulator. It stores processes that have arrived and are waiting to be scheduled.
Contains the scheduling logic. This component decides:
- how the ready queue is ordered
- which process should be selected next
The supported algorithms are:
- FIFO
- SJF
- Round Robin
This is the central coordinator of the simulation. It manages the overall flow of execution, including:
- loading processes
- moving arriving processes into the ready queue
- assigning processes to processors
- advancing time
- handling preemption for RR
- collecting completed processes
- computing summary statistics
Tracks and computes the performance metrics for each run, including:
- turnaround time
- waiting time
- response time
Generates charts and visual comparisons for the simulation results. This component is used to compare scheduling algorithms and performance across different parts of the project.
Generates or loads synthetic process data used as input for the simulator. This allows the project to run without manually creating process lists each time.
Contains input data files such as processes.csv, which are used to feed the simulator with process information. Also stores output metric data on the algorithms used for each part.
The simulation follows this high-level flow:
- Processes are loaded from CSV or generated from the data generator.
- The simulator checks which processes have arrived.
- Processes are placed into the ready queue.
- The scheduler decides which process should run next.
- Idle processors accept eligible processes.
- Processors execute work for one time unit.
- Completed or preempted processes are handled.
- The system continues until all scheduled processes finish.
- Python (Recommend 3.8 or higher)
- Required Libaries:
matplotlib- For generating result charts and visualizationsnumpy- For numerical operations and statistical calculations
pip install matplotlib numpyRun the project with:
python main.py