This repository provides an implementation of various process scheduling algorithms in C++. The program simulates the behavior of scheduling algorithms and generates performance statistics and timelines for process execution. It supports multiple scheduling strategies, including both preemptive and non-preemptive techniques.
- Features
- Supported Scheduling Algorithms
- How to Use
- Input File Format
- Output Format
- Build and Run
- Code Structure
- Contributing
- License
- Supports various scheduling algorithms.
- Provides visual execution timelines.
- Computes and displays statistics such as:
- Finish time
- Turnaround time
- Normalized turnaround time
- Flexible configuration for quantum values (for algorithms like Round Robin and Feedback).
- Modular and extensible code.
The following algorithms are implemented:
- First-Come, First-Serve (FCFS)
- Round Robin (RR)
- Shortest Process Next (SPN)
- Shortest Remaining Time (SRT)
- Highest Response Ratio Next (HRRN)
- Feedback Queue (FB-1)
- Feedback Queue with Incremental Quantum (FB-2i)
- Aging
-
Clone the repository:
git clone https://github.com/your-username/process-scheduling-simulator.git cd process-scheduling-simulator -
Prepare an input file following the format specified in the Input File Format section.
-
Compile and run the program:
g++ -std=c++17 -o scheduler main.cpp parser.cpp ./scheduler
-
The program will output either the execution timeline or the statistics, depending on the operation mode.
The input file should describe the processes and their attributes. Example format:
<operation> <algorithm> <quantum>
<process_name> <arrival_time> <service_time>
...
trace 2 4
P1 0 5
P2 2 3
P3 4 2
- Operation:
tracefor execution timeline orstatsfor performance statistics. - Algorithm: Algorithm ID (1 to 8) as listed above.
- Quantum: Time quantum (only applicable for algorithms like Round Robin).
- Process Details: Each line specifies a process with its name, arrival time, and service time.
Visual representation of the process execution timeline.
Example:
0 1 2 3 4 5 6 7 8 9
---------------------------------------
P1 |* * * * *|
P2 |. . * * *|
P3 |. * *|
---------------------------------------
Tabular representation of finish time, turnaround time, and normalized turnaround time.
Example:
FCFS
Process | P1 | P2 | P3 |
Arrival | 0 | 2 | 4 |
Service | 5 | 3 | 2 |
Finish | 5 | 8 | 10 |
Turnaround | 5 | 6 | 6 |
NormTurn |1.00 |2.00 |3.00 |
-
Compile the program:
g++ -std=c++17 -o scheduler main.cpp parser.cpp
-
Run the program:
./scheduler
main.cpp: Main entry point of the program.parser.handparser.cpp: Handles input parsing and validation.algorithms.cpp: Implements the various scheduling algorithms.timeline.cpp: Handles timeline creation and visualization.
Contributions are welcome! If you want to add features or fix issues:
- Fork the repository.
- Create a feature branch.
- Commit your changes.
- Open a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.