Spark Kernel simulates process scheduling on multiple CPU cores using various scheduling algorithms. It reads process information from a file, simulates their execution, and produces a Gantt chart showing process execution across available CPUs over time.
The diagram above illustrates the core components of the Spark Kernel system and their interactions.
- Support for multiple CPUs
- Multiple scheduling algorithms:
- First-In-First-Out (FIFO)
- Round Robin with configurable time slice
- Priority-based scheduling
- Process types:
- CPU-bound processes (C)
- I/O-bound processes (I)
- Visual representation of scheduling via Gantt chart
- Configurable via command-line arguments
g++ -pthread ./src/main.cpp ./src/Kernel.cpp ./src/Scheduler.cpp ./src/Process.cpp -o spark-kernel./spark-kernel [process_file] [num_cpus] [scheduler_type] [time_slice] [output_file]process_file: Path to the file containing process informationnum_cpus: Number of CPU cores to simulatescheduler_type: (optional)f- FIFOr- Round Robinp- Priority-based
time_slice: Required if using Round Robin scheduler (in tenths of a second)output_file: (optional) Name of the file to write output
# FIFO scheduling with 4 CPUs
./spark-kernel tests/Processes1.txt 4 f output.txt
# Round Robin scheduling with 4 CPUs and time slice of 0.5
./spark-kernel tests/Processes1.txt 4 r 5 output.txt
# Priority-based scheduling with 4 CPUs
./spark-kernel tests/Processes1.txt 4 p output.txtThe process file should contain tab-separated values with the following columns:
PROCNAME PRIORITY ARRIVAL-TIME PROC-TYPE CPU-TIME I/O-TIME
Where:
PROCNAME: Process namePRIORITY: Process priority (lower value = higher priority)ARRIVAL-TIME: Time at which the process arrivesPROC-TYPE: Process type ('C' for CPU-bound, 'I' for I/O-bound)CPU-TIME: Time required for CPU executionI/O-TIME: Time for I/O operations (only for I/O-bound processes)
If CPU-TIME and I/O-TIME are not provided, they will be randomly generated.
The program outputs a Gantt chart showing the execution of processes on each CPU over time. If an output file is specified, results will be written to that file.
Process.cpp/h: Handles process data and file I/OKernel.cpp/h: Core scheduling logicScheduler.cpp/h: Implements different scheduling algorithmsmain.cpp: Program entry point
