0% found this document useful (0 votes)
1K views

Case Study On Different Scheduling Algorithms

This document compares different scheduling algorithms: first-come, first-served (FCFS), shortest job first (SJF), round robin, and priority-based. It provides pseudocode for each algorithm and compares their performance in terms of throughput, average waiting time, and overhead. The conclusion is that round-robin scheduling allows equal CPU time for each job but may not be suitable for real-time applications, while priority-based scheduling is a variant that allows variable CPU times based on priority levels.

Uploaded by

Akshat Pattiwar
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1K views

Case Study On Different Scheduling Algorithms

This document compares different scheduling algorithms: first-come, first-served (FCFS), shortest job first (SJF), round robin, and priority-based. It provides pseudocode for each algorithm and compares their performance in terms of throughput, average waiting time, and overhead. The conclusion is that round-robin scheduling allows equal CPU time for each job but may not be suitable for real-time applications, while priority-based scheduling is a variant that allows variable CPU times based on priority levels.

Uploaded by

Akshat Pattiwar
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Case Study on Different Scheduling Algorithms

FCFS Scheduler Algorithm


Algorithm :
1- Enter the processes, as well as their burst time (bt).

2- Calculate the amount of time each procedure will take to complete.

3- Because the first process is not required to wait, the waiting time for process 1 will be
zero.

4- Calculate the waiting time for all other processes, i.e., waiting time[i] = burst time[i-1]
+ waiting time[i-1] for process i.

5- Calculate the turnaround time for all processes

as waiting time + burst time.

6- Calculate the average waiting time by multiplying total waiting time by the number of
processes.

7- Calculate the average turnaround time by multiplying total turn around time by the
number of processes.

Shortest Job First Scheduler Algorithm(Preemptive)

Algorithm :
1- Continue traversing until all of the processes are finished.
a) At each time lap, locate the process with the least amount of time left.
b) Cut it by one minute.
c) Determine if the time left is zero.
d) Add to the process completion counter.
e) Completion time of current process = current_time +1;
f)Calculate the amount of time it will take to finish each process.
wt[i]= Time to completion - arrival time-burst time
g)Add one to the time lap.

2- Find turnaround time (waiting_time+burst_time).

Shortest Job First Scheduler Algorithm(Non – preemptive)


Algorithm :
1. Arrange all of the procedures in order of arrival time.
2. Then choose the procedure with the shortest arrival time and the shortest burst
time.
3. After the process is completed, create a pool of processes that will run until the
preceding process is completed, and choose the process with the shortest Burst
time from the pool.

Round Robin Scheduler Algorithm

Algorithm :

1- Make an array to keep track of how much time is left for processes to burst. This
array is a duplicate of the burst times array at first.

2- Make a new array to keep track of process waiting times. Set the value of this array
to 0.

3- Initialize time : t = 0
4- Continue traversing all processes as long as they aren't completed. If you haven't
already, complete the i'th procedure.

a- If remaining burst time > quantum

(i) t = t + quantum

(ii) remaining burst time -= quantum;

c- Else // Last cycle for this process

(i) t = t + remaining burst time;

(ii) waiting time = t – burst time

(ii) remaining burst time = 0; // This process is over

Priority Based Scheduler Algorithm

Algorithm

1. To begin, provide the arrival time, burst time, and priority of the processes.

2. If two or more processes have the same earliest arrival time, the higher priority
process will be scheduled first.

3. Further procedures will now be planned depending on the time and priority of
their arrival. (We're assuming that the lower the priority number, the more important
it is.) Sort by process number if two processes have the same priority.
Comparisons
Round Robin vs FCFS
It means that when we see which algorithm is completing more processes per
unit time. For example, if we see one algorithm that gives a throughput of 1
process/ sec and another gives 3 processes/sec we will say the latter is a better
choice.
If there are only a limited number of processes that need to run on a system then
every algorithm will give the same throughput, but generally, there are lots of
processes working in the background. So it may happen that one process only
needs one microsecond to finish but will get that one microsecond after 3
seconds then the processor’s throughput will definitely decrease. FCFS takes on
one process and completes it before giving the processor to another process. On
the other hand, round-robin gives a chunk of the processor’s time to each
process. Hence better throughput.

Round Robin vs SJF


SJF is also non-preemptive but its preemptive version is also there called
Shortest Remaining Time First (SRTF) algorithm. Round-Robin (RR) is
preemptive. for SJF The average waiting time for a given set of processes is
minimum whereas for RR The average waiting time for a given set of processes
is quite small and depends on the time quantum. in sjf A long process may never
get executed and the system may keep executing the short processes. but in RR
Each process is executed and every user feels that his work is being done as the
CPU gives an equal amount of time to each process. In the case of SJF, elapsed
time should be recorded, which results in more overhead on the processor. In the
case of RR, if the time quantum is very small then the context switch takes place
again and again after very short intervals of time which leads to overhead.

Priority scheduling vs Round Robin


Priority Scheduling is both preemptive and non-preemptive. Round-Robin (RR) is
preemptive. in priority scheduling the average waiting time and average response
time is unknown beforehand whereas in Round Robin The average waiting time
for a given set of processes is quite small and depends on the time quantum. in
priority scheduling It is easy to implement and best suited for real-time operating
systems but in RR It is quite easy to implement RR in any system. in priority
scheduling The problem of blocking a process can be solved using aging but in
RR Each process is executed and every user feels that his work is being done as
the CPU gives an equal amount of time to each process.

Conclusions
Round-robin scheduling allows an equal amount of CPU time for each
job. Tasks are in a circular queue in their most basic form, and when a
job's assigned CPU time expires, the task is moved to the back of the
queue, and a new task is added to the front. In many real-time
applications, round-robin scheduling is insufficient since each job may
demand variable amounts of CPU resources depending on the
intricacy of the processing performed. Priority-based scheduling is a
variant of pure round-robin scheduling in which activities with the
same priority levels receive equal amounts of CPU time. It's also
possible to give each job a varied maximum CPU time.

You might also like