Skip to content

A simulation of different CPU scheduling algorithms using pygame

Notifications You must be signed in to change notification settings

harisankar01/CPU-Scheduling-Simulation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Windows

CPU Scheduling Simulation

CPU scheduling is used to determine which process or task must be done first when many process are waiting to be completed. In this project I have created a simulation of these three algorithms to understand them more easier.

CPU use may algorithms such as

  • First Come First Served(FCFS)
  • Shortest Job First(SJF)
  • Round robin

Basically a process have a fixed execution time(time required to complete the process), waiting time(time the process has to wait to be processed). These algorithms are designed to reduce waiting time and ensure that the CPU is continuously executing processes without being idle.

FCFS

The first process which come will be processed by the CPU before processing the next process.

SJF

The process which have least time of execution will be processed first.

Round Robin

The process is processed in multiple steps hence giving an equal chance to all processes. This is the most efficient algorithm for cpu scheduling

Install with pip

You can easily install the simulations of these three algorithms using pip. The name of the package is CpuSchedulingSimulation and the module used is Cpu_scheduling_algorithms. You can find the documentation here

pip install CpuSchedulingSimulation

Note: This will also install pygame(version 2.1.2)

Examples

Then just import the package and run the functions named as algorithms to see the simulation in action.

import Cpu_scheduling_algorithms as css
css.FCFS()
css.SJF()
css.Round_Robin()

Cloning the repo

Use the following command to clone the repo to your local system.

git clone https://github.com/harisankar01/CPU-Scheduling-Simulation.git

Then go into the folder to execute the functions.

cd CPU-Scheduling-Simulation

Packages used

Pygame a popular game library in pyton is used in this project to create simulation of the scheduling process

pip install pygame

Then finally run the main file which is FCFS.py and understand CPU scheduling easily.

python3 FCFS.py

Note: These simulations can be used to understand CPU scheduling effectively, if you have basic knowledge of CPU scheduling algorithms

Images

Screenshot (23) Screenshot (26) Screenshot (28)