OPERATING SYSTEM LAB – DA-4
NAME – JITARTH VARDHAN SINGH
Simulation of CPU scheduling algorithms (FCFS, SJF, Priority and Round Robin)
1)FCFS;
First Come First Serve (FCFS) Scheduling
🔹 Definition
FCFS is the simplest CPU scheduling algorithm.
It is non-preemptive, meaning once a process starts executing, it runs
until it finishes.
Processes are executed in the order of their arrival time (like a queue at
a ticket counter).
A)With 0 arrival time and with non 0 arrival time;
B)SJF scheduling ;
Theory-Definition
SJF (Shortest Job First) is a CPU scheduling algorithm where the process
with the shortest burst time is executed next.
It can be non-preemptive or preemptive:
o Non-preemptive SJF: Once a process starts execution, it runs until
completion.
o Preemptive SJF (also called Shortest Remaining Time First – SRTF):
If a new process arrives with a smaller burst time than the
remaining time of the current process, the CPU is given to the new
process.
WITH 0 ARRIVAL TIME
WITH NON 0 ARRIVAL TIME;
C)PRIORITY SCHEDULING;
THEORY-Definition
Priority Scheduling is a CPU scheduling algorithm in which each process
is assigned a priority value.
The CPU is allocated to the process with the highest priority.
Priorities can be defined internally (e.g., memory requirements,
deadlines) or externally (e.g., importance, user preference).
It can be preemptive or non-preemptive:
o Non-preemptive: Once a process starts execution, it cannot be
stopped until it finishes.
o Preemptive: If a new process arrives with a higher priority, it
preempts the currently running process.
D) ROUND ROBIN SCHEDULING;
Definition
Round Robin (RR) is a preemptive CPU scheduling algorithm designed
especially for time-sharing systems.
Each process is assigned a fixed time slice (time quantum).
Processes are executed in a circular queue order.
If a process does not finish within its time quantum, it is preempted
and placed back in the ready queue to wait for the next turn.
RESULT – ALL THE SCHEDULING PROGRAMS ARE SUCCESSFULLY EXECUTED IN C
LANGUAGE.