CPU-Scheduling-Algorithms
CPU-Scheduling-Algorithms
NAME:
Prince Jimu BIS/22/SS/009
COURSE
OPERATING SYSTEMS (OPS-311)
DUE DATE
7th March 2025
CPU SCHEDULING ALGORITHMS
1.0 INTRODUCTION
The CPU, being the most important part of the internal hardware system of any computing
device, is responsible for handling each process requested by the user or triggered by another
process. This means that the CPU handles thousands of processes all of which rely on the
completion or execution of another process. The CPU can execute one process at a time (This is
true for single core processors as multi-core CPUs share processes, one for each core (BBC,
2025)) and therefore needs a way of scheduling the order at which processes are allowed CPU
time and executed. This discussion outlines some of the most common scheduling algorithms
used by the OS to ensure that the CPU is used efficiently.
2.0 DEFINITIONS
Some of the terms to be used frequently in this discussion:
2.1 Turnaround time: The total time taken from the initiation of the process to the time it
completes executing. (geeksforgeeeks, 2024)
2.2 Waiting time: Defined as the total amount of time a process stays in the “ready queue” while
another process is being executed (unacademy, 2025).
2.3 Burst-time: The total time a process takes to execute.
2.4 Non pre-emptive scheduling: This a type of scheduling algorithm that allows a process to
run until it is finished executing or gets set to a waiting state for a certain event.
2.5 Pre-emptive scheduling: this is when a process in execution is “involuntarily” released from
the CPU when another process with higher priority needs to be executed. (Omar, H., et. al,
2021).
3.0 ALGORITHMS
3.1 ROUND ROBIN
This algorithm involves the allocation of a fixed time for each process called a “quantum”.
Recall that all the processes are stored in a queue where the CPU fetches a process to execute. As
a data structure, queues are accessed by “en-queuing” an object on one end and de-queuing one
object at a tie on the other. The CPU de-queues a process and executes it within the pre-specified
quantum. If the process execution takes longer than the specified quantum, the CPU will create a
new process and en-queue it back to the queue (it goes back to the end of the line). This is an
example of a preemptive scheduling algorithm because the CPU will stop the current process and
begin another if its quantum runs out.
According to Stallings (2011), choosing the next process to be executed after one has completed
or has been preempted is done by FCFS basis. This means that, if the quantum is longer than the
process with the highest burst-time, the Round Robin algorithm will work the same way as FCFS
algorithm.
This algorithm raises a few problems. The first one is comes in when the specified quantum is
too small for some processes that they get dropped multiple times for passing the specified
quantum. The second problem arises when the quantum is too big for some other processes that
it creates an overhead of waiting time.
The solution to these problems is the introduction of Variable Quantum Round Robin. This
algorithm is an enhancement of the RR. The difference is, here, the quantum size is variable. A
process is given a quantum based on its requirements (Mohammed. A., Kotp. Y., 2023). This
solves the problem of waiting time overhead by allowing processes with shorter burst-time to
execute within a reasonable quantum that will be just enough for the specific process. This
significantly reduces the average waiting time for each process.
Variable Quantum Round Robin also solves the problem of dropping large processes due to
insufficient fixed quantum since in this case, larger or more demanding processes will be given a
reasonable quantum that is enough for the process to execute once and complete its execution.
3.2 FIRST COME, FIRST SERVED:
FCFS is an easier to understand algorithm since it works on the same principle that a normal
queue works on. The first process to request for the CPU (the first to arrive in the ready queue) is
processed first and the last to arrive is processed last, in that order. This is regardless of the burst-
time or requirements of the process. FCFS is an example of a Non pre-emptive scheduling
algorithm.
The main advantage of this algorithm is that there is less overhead as compared to other
scheduling algorithms such as Round Robin (RR) since there is no pre-specified quantum for a
process. Therefore, with FCFS, a process will execute until it is done and when it is done, it exits
the CPU immediately. This means the next process will not experience a long waiting time in the
queue.
The main disadvantage is that, if a process with very high burst-time enters the queue first, the
next process, regardless of its burst-time size will have to wait longer for the previous process to
be completed even if it would’ve completed executing faster than the previous process.
Another notable disadvantage is that FCFS favors processor-bound processes (Stallings, W.,
2011). Stalling (2011) shares the difference in treatment between processes that need the
processor more (Processor-bound) and those that need more of I/O than the processor (I/O
bound). This is seen when, for example, a processor bound process is in the ready queue and a
few more I/O bound processes join the queue. The processor may be take a long time executing
the processor-bound processor leaving the I/O bound processes in the ready queue and the I/O
devices in idle state since the processes that require the I/O devices have not been processed and
sent interrupts yet. This brings inefficiency in the use of the CPU but mostly on I/O devices.
3.3 SHORTEST JOB FIRST
This is a scheduling algorithm that estimates the burst-times of processes in the ready queue. It
uses these estimates to decide which process needs to execute first. The process with the shortest
estimated burst-time is executed first. Some sources refer to it as “Shortest Process Next (SPN)”
according to Mohammed and Kotp (2023).
SJF reduces the average waiting time for processes since the processes with shorter burst-time
are executed first and free up resources quicker than would the processes with a higher burst-
time. However, this means that the processes with a longer burst-time may stay in the ready
queue for a longer time if much shorter processes are being created.
This algorithm can be preemptive or non-preemptive (Abraham, S. et. al., 2018).
In the preemptive version, the CPU will look for the shortest estimated burst-time in the ready
queue. It will execute this process until it finishes or until another process enters the queue with a
lower burst-time than the remaining time to finish executing the current process. In this case, the
CPU will preempt and execute the new process first. This is called shortest-remaining-time-first
algorithm.
The non-preemptive version is the one that runs a process till it finishes then looks for the next
shortest burst-time in the queue.
The following example shows a scenario where preemptive SJF is necessary and better than non-
preemptive:
Process Arrival Time (milliseconds) Burst-time(milliseconds)
(Estimated)
P1 0 8
P2 1 4
P3 2 9
P4 3 5
5.0 CONCLUSION
From the study conducted in this discussion, multi-level Feedback Queue scheduling algorithm
is the most efficient algorithm. Despite the complexity of implementing it, it provides a way of
executing process fairly as compared to other algorithms.
6.0 References
Abraham, S., Greg, G., & Peter Baer, G. (2018). Operating System Concepts.-10th.
Ali, S. M., Alshahrani, R. F., Hadadi, A. H., Alghamdi, T. A., Almuhsin, F. H., & El-Sharawy,
study. International Journal of Computer Science & Network Security, 21(1), 19-26.
https://www.bbc.co.uk/bitesize/guides/zws8d2p/revision/2
Geeksforgeeks. (2024). Difference Between Turn Around Time (TAT) and Waiting Time (WT) in
tat-and-waiting-time-wt-in-cpu-scheduling/
https://unacademy.com/content/cbse-class-11/difference-between/turnaround-time-and-waiting-
time-in-cpu-scheduling/#:~:text=Waiting%20time%20(WT)%20is%20defined,before
%20it%20reaches%20the%20CPU.
https://github.com/yousefkotp/CPU-Scheduling-Algorithms
Omar, H. K., Jihad, K. H., & Hussein, S. F. (2021). Comparative analysis of the essential CPU
2750.
Stallings, W. (2011). Operating systems: internals and design principles. Prentice Hall Press.