Skip to content

codebyahmed/spark-kernel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spark Kernel

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.

Architecture

Spark Kernel Architecture

The diagram above illustrates the core components of the Spark Kernel system and their interactions.

Features

  • 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

Compilation

g++ -pthread ./src/main.cpp ./src/Kernel.cpp ./src/Scheduler.cpp ./src/Process.cpp -o spark-kernel

Usage

./spark-kernel [process_file] [num_cpus] [scheduler_type] [time_slice] [output_file]

Parameters:

  • process_file: Path to the file containing process information
  • num_cpus: Number of CPU cores to simulate
  • scheduler_type: (optional)
    • f - FIFO
    • r - Round Robin
    • p - 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

Examples:

# 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.txt

Input File Format

The 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 name
  • PRIORITY: Process priority (lower value = higher priority)
  • ARRIVAL-TIME: Time at which the process arrives
  • PROC-TYPE: Process type ('C' for CPU-bound, 'I' for I/O-bound)
  • CPU-TIME: Time required for CPU execution
  • I/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.

Output

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.

Project Structure

  • Process.cpp/h: Handles process data and file I/O
  • Kernel.cpp/h: Core scheduling logic
  • Scheduler.cpp/h: Implements different scheduling algorithms
  • main.cpp: Program entry point

About

A CPU scheduler simulator implementing multiple scheduling algorithms (FIFO, Round-Robin, Priority) with multi-CPU support.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages