By now in this operating system tutorial you have learned about the types of operating systems, services of operating system, properties of operating systems, processes, process scheduling and now you will learn about some process scheduling algorithms using which your system chooses the processes.
First Come First Serve (FCFS)
Let's begin with the Benefits:
FCFS algorithm doesn't involve any complicated logic, it just sets the function requests in a queue and executes them one by one.
Hence, FCFS is easy and straightforward to implement.
Eventually, every process will get an opportunity to run, so starvation doesn't occur.
It's time for the Disadvantages:
There is no substitute for preemption of a process. If a process is started, then the CPU executes the method until it ends.
Because there's no preemption, if a process executes for an extended time, the processes within the back of the queue will need to wait an extended time before they get an opportunity to be executed.
Shortest Job First (SJF)
Beginning with the Benefits of Shortest Job First scheduling algorithm.
According to the definition, short processes are executed first then followed by longer processes.
The throughput is increased because more processes are often executed in less amount of your time.
And the Disadvantages:
The time needed by a process should know by the CPU in advance, which is impossible.
Longer processes will have more waiting time, eventually, they'll suffer starvation.
Note: Preemptive Shortest Job First scheduling will have equivalent advantages and drawbacks to those for SJF.
Round Robin (RR)
Here are some benefits of applying the Round Robin Scheduling:
Each process is served by the CPU for a hard and fast time quantum, so all processes are given an equivalent priority.
Starvation doesn't occur because, for every round-robin cycle, every process is given a hard and fast time to execute. No process is left behind.
and here comes the Disadvantages:
The throughput in RR largely depends on the selection of the length of the time quantum. If time quantum is longer than needed, it tends to exhibit an equivalent behaviour as FCFS.
If time quantum is shorter than needed, the number of times that CPU switches from one process to a different process, increases. This results in a decrease in CPU efficiency.
Priority-based Scheduling
Benefits of Priority Scheduling:
The importance of a process is generally selected strengthened memory necessity, time constraint or user inclination. for instance, a high-end game will have better graphics, which suggests the method which updates the screen during a game will have higher priority to realize better graphics performance.
Some Disadvantages:
A second scheduling algorithm is required to schedule the processes which have an equivalent priority.
In tactical priority scheduling, a improved priority process can accomplish before an previously executing lower priority process. If the lower priority process keeps expecting higher-priority processes, starvation occurs.
Usage of Scheduling Algorithms in several Situations
Every scheduling algorithm features a sort of situation where it's the simplest choice. Let's check out different such situations:
Situation 1:
The incoming processes are short and there's no need for the processes to execute during a specific order.
In this scenario, FCFS functions best in variance to SJF and RR, since, the processes are short which suggests that no process will await an expanded time. When each process is executed one by one, every process is going to be executed eventually.
Situation 2:
The processes are a fusion of long and short processes and hence the job will only be performed if all the processes are fulfilled successfully while a given time.
Round Robin scheduling works efficiently here because it doesn't cause starvation and gives an equal time quantum for every process.
Situation 3:
The processes are a mixture of user-based and kernel-based processes.
Priority-based scheduling works efficiently during this case because generally kernel-based processes have a higher priority in comparison to user-based processes.
For example, the scheduler itself may be a kernel-based process, it should run first in order that it can schedule other processes.