CSBP 315 Theory Assignment 2
Group Members:
Alyazya Almazrouei 202320927
Shamma Al Ali 202331782
Shouq Alnuaimi 202208820
Part 1
Solution:
Following are the two chosen Scheduling algothrithms below:
1. Shortest job first (SJF): it can also be considered as Non-Preemptive
2. Round Robin (RR): it can also be considered as Preemptive
1. Shortest Job First (SJF) Scheduling:
it select the process that has the smallest CPU bust time to execute next.
Types:
Non-preemptive:
Non-preemptive scheduling is a CPU scheduling method where, once a process is allocated the
CPU, it runs to completion or until it voluntarily enters a waiting state
Advantages of Non-Preemptive Scheduling:
1. It is easy to implement in an operating system. It was used in Windows 3.11 and early
macOS.
2. It has a minimal scheduling burden.
3. Less computational resources are used.
Disadvantages of Non-Preemptive Scheduling:
1. It is open to denial of service attack. A malicious process can take CPU forever.
2. Since we cannot implement round robin, the average response time becomes less.
The Round Robin (RR) scheduling algorithm is primarily intended for use in time-sharing
systems. This approach is similar to FCFS scheduling; however, Round Robin(RR) scheduling
incorporates preemption, allowing the system to switch between processes. Preemption enables
the process to be forcefully taken out of the CPU.
Page 1 of 4
Round Robin (RR) scheduling algorithm have some advantages and disadvantges that are given
below:
Advantages of Round Robin Scheduling:
Since the CPU serves each process for a fixed time quantum, all processes are assigned the
same priority.
As each round-robin cycle gives every process a predetermined time to run, starvation does not
occur.
No process is left unattended.
Disadvantages of Round Robin Scheduling:
1. The choice of the time quantum has a significant impact on throughput in round robin
scheduling.
2. If the time quantum is longer than required, the algorithm behaves similarly to FCFS.
3. If the time quantum is too small, the number of context switches increases, which reduces
CPU efficiency
Our opinion about which algorithm is better?
Following are the criterion have been considered to decide the which algorithm is better below:
Criterion Shorttest job first (SJF) Round Robin
Waiting Time Waiting Time Waiting Time
airness Airness airness
Starvation Possibility Starvation Possibility Starvation Possibility
Best Use Case Best Use Case Best Use Case
Conclusion:
In summary we can that Round Robin is best if fairness and responsiveness are required and on
the other hand, Shortest job first (SJF) is best if minimizing waiting time is more important.
Page 2 of 4
Part 2:
Given data for processes:
Process Burst Time Priority
P1 8 3
P2 4 1
P3 2 2
P4 9 2
P5 3 4
PART A: SCHEDULING ALGORITHMS
1. First come First Serve (FCFS Scheduling): According to this Scheduling method, order
will be based on processes so order is give as:
Order: P1 → P2 → P3 → P4 → P5
2. SJF (Non-Preemptive): According to this Scheduling method, order will be based on burst
time so order is give as:
Order: P3 → P5 → P2 → P1 → P4
3. Priority Scheduling (Non-Preemptive): According to this Scheduling method, order will be
based on priority like higher priority number will come first and lower priority number will
come in last so order is give as:
Priority Order: P5 > P1 > P3 > P4 > P2
4. Round Robin (Quantum = 2): According to this Scheduling method, order will be based on
Round Robin method and Each process gets 2 ms of CPU time in a cyclic order. If a
process still has burst time remaining after its 2 ms slice, it goes to the end of the queue
and waits for the next turn so order is give as:
Initial burst time for each processes → P1:8, P2:4, P3:2, P4:9, P5:3
After that we give each process 2 ms at a time in rounds
P1 → P2 → P3 → P4 → P5 → P1 → P2 → P4 → P5 → P1 → P4 → P1 → P4
0 2 4 6 8 10 12 14 16 17 19 21 23 26
Page 3 of 4
B) SCHEDULING CALCULATIONS
After doing the calculations:
Turnaround Time Table:
Proces FCFS SJ Priorit Round
s F y Robin
P1 8 17 11 23
P2 12 9 26 14
P3 14 2 13 6
P4 23 26 22 26
P5 26 5 3 17
c) After doing the calculations:
Waiting Time Table:
Process FCFS SJF Priorit Round Robin
y
P1 0 9 3 15
P2 8 5 22 10
P3 12 0 11 4
P4 14 17 13 17
P5 23 2 0 14
Conclusion: In summary we can say that Shortest job first (SJF) gives the lowest waiting time but
may lead to starvation of longer processes. Round Robin is fairer and suitable for real-time time-
sharing environments.
Page 4 of 4