This project simulates different process scheduling policies by running CPU-bound and I/O-bound tasks under various scheduling strategies. The objective is to analyze how different scheduling algorithms impact the turnaround time of processes.
- cpu_bound.c: Implements a CPU-intensive computation to simulate CPU-bound tasks.
- io_bound.c: Simulates an I/O-heavy process by performing repeated I/O operations.
- main.c:
- Manages process creation and execution.
- Sets scheduling policies (
SCHED_OTHER
,SCHED_RR
,SCHED_FIFO
). - Assigns tasks based on the specified I/O ratio.
- Measures turnaround time for analysis.
- Makefile:
- Defines rules for compiling the project.
- Provides
make build
andmake clean
targets.
- simulation.sh:
- Automates compilation and execution.
- Runs simulations with different scheduling policies and I/O ratios.
- Stores results in
simulation_results.txt
.
- simulation_results.txt: Stores the output logs of the simulations for later analysis.
Ensure that gcc
is installed on your system. This project is intended for Linux-based operating systems. To install the necessary dependencies, run:
sudo apt update && sudo apt install gcc make
Compile the source code using:
make build
This will generate the following binaries:
cpu_bound
io_bound
main
Since modifying scheduling policies requires root privileges, execute the script with:
sudo ./simulation.sh
After execution, check the simulation results using:
cat simulation_results.txt
- The script first ensures it is executed with root privileges.
- It compiles the project using
make build
. - The script iterates through different I/O ratios and scheduling policies:
- I/O Ratios Tested:
0.1
,0.6
- Scheduling Policies:
SCHED_OTHER
,SCHED_RR
,SCHED_FIFO
- I/O Ratios Tested:
- For each combination, the
main
program is executed, simulating 50 processes. - The turnaround time for each process is recorded and stored in
simulation_results.txt
.
You can modify the simulation parameters in simulation.sh
:
- Adjust the
io_ratios
array to test different I/O ratios. - Change the
scheduling_policies
array to include or exclude policies.
The results file (simulation_results.txt
) will contain entries like:
IO_RATIO=0.1, POLICY=SCHED_RR
PID Type Start Time End Time Turnaround Time
12345 IO 0.123456 0.567890 0.444434
...
Average Turnaround Time: 0.345678
-----------------------------------------
- The
main.c
file creates 50 child processes, assigning them as CPU-bound or I/O-bound based on the specified ratio. cpu_bound.c
executes a loop-intensive task, whileio_bound.c
performs periodic file writes and sleeps.- The scheduling policy affects process execution order and turnaround time.
To remove compiled binaries and reset the project, run:
make clean
This simulation provides insights into how different scheduling strategies impact CPU-bound and I/O-bound processes. The recorded results help analyze the efficiency of scheduling algorithms under varying workloads.
https://github.com/faezehghiasi/Process-Scheduling-Simulation
Leave a Reply