This project is a C implementation of common CPU scheduling algorithms used in Operating Systems. It calculates the Waiting Time and Turnaround Time for a set of processes based on the selected algorithm.
-
FCFS (First Come First Served)
- Executes processes in the exact order they arrive.
- Non-preemptive.
-
SJF (Shortest Job First)
- Selects the process with the shortest burst time available.
- Non-preemptive (once a process starts, it finishes).
-
RR (Round Robin)
- Allocates a fixed time slice (Quantum) to each process.
- Preemptive (switches between processes cyclically).
- src/: Contains the source code files (.c).
- include/: Contains the header files (.h).
- main.c: The main entry point with the user menu.
- input.txt: The file containing process data.
- output.txt: The file where results are saved.
- Makefile: Script to compile the project easily.
- Open your terminal in the project folder.
- Compile the project: make
- Run the executable: ./scheduler
- To clean up build files: make clean
If you do not have Make installed, you can compile using gcc: gcc main.c src/utils.c src/fcfs.c src/sjf.c src/rr.c -o scheduler -I./include
The program reads process data from "input.txt". IMPORTANT: The file must contain numbers only. Do not write text headers like "ID" or "Arrival".
The format for each line is:
[Process ID] [Arrival Time] [Burst Time]
Example content for input.txt:
1 0 7
2 2 4
3 4 1
4 5 4
- Fill "input.txt" with your process data.
- Run the program.
- Select an algorithm from the menu:
- Enter 1 for FCFS.
- Enter 2 for SJF.
- Enter 3 for Round Robin (you will be asked to enter the Time Quantum).
- The output table will be displayed in the terminal and saved to "output.txt".