Operating Systems SJF (Shortest Job First) Scheduling [Non-Preemptive] 2022
What is Shortest Job First Scheduling?
Shortest Job First (SJF) is an algorithm in which the process having the smallest execution time is chosen for the next execution. This scheduling method can be preemptive or non-preemptive. It significantly reduces the average waiting time for other processes awaiting execution. The full form of SJF is Shortest Job First.
There are basically two types of SJF methods:
Non-Preemptive SJF
Preemptive SJF
Characteristics of SJF Scheduling
It is associated with each job as a unit of time to complete.
This algorithm method is helpful for batch-type processing, where waiting for jobs to complete is not critical.
It can improve process throughput by making sure that shorter jobs are executed first, hence possibly have a short turnaround time.
It improves job output by offering shorter jobs, which should be executed first, which mostly have a shorter turnaround time.
Non-Preemptive SJF
In non-preemptive scheduling, once the CPU cycle is allocated to process, the process holds it till it reaches a waiting state or terminated.
Preemptive SJF
In Preemptive SJF Scheduling, jobs are put into the ready queue as they come. A process with shortest burst time begins execution. If a process with even a shorter burst time arrives, the current process is removed or preempted from execution, and the shorter job is allocated CPU cycle.
-------------------------------------------------------------------
Advantages of SJF
Here are the benefits/pros of using SJF method:
------------------------------------------------------------------
SJF is frequently used for long term scheduling.
It reduces the average waiting time over FIFO (First in First Out) algorithm.
SJF method gives the lowest average waiting time for a specific set of processes.
It is appropriate for the jobs running in batch, where run times are known in advance.
For the batch system of long-term scheduling, a burst time estimate can be obtained from the job description.
For Short-Term Scheduling, we need to predict the value of the next burst time.
Probably optimal with regard to average turnaround time.
---------------------------------------------------------------------------
Disadvantages/Cons of SJF
Here are some drawbacks/cons of SJF algorithm:
-----------------------------------------------------------------------------
Job completion time must be known earlier, but it is hard to predict.
It is often used in a batch system for long term scheduling.
SJF can’t be implemented for CPU scheduling for the short term. It is because there is no specific method to predict the length of the upcoming CPU burst.
This algorithm may cause very long turnaround times or starvation.
Requires knowledge of how long a process or job will run.
It leads to the starvation that does not reduce average turnaround time.
It is hard to know the length of the upcoming CPU request.
Elapsed time should be recorded, that results in more overhead on the processor.
----------------------------------------------------------------------------------------------------------------------------------
Summary
SJF is an algorithm in which the process having the smallest execution time is chosen for the next execution.
SJF Scheduling is associated with each job as a unit of time to complete.
This algorithm method is helpful for batch-type processing, where waiting for jobs to complete is not critical.
There are basically two types of SJF methods 1) Non-Preemptive SJF and 2) Preemptive SJF.
In non-preemptive scheduling, once the CPU cycle is allocated to process, the process holds it till it reaches a waiting state or terminated.
In Preemptive SJF Scheduling, jobs are put into the ready queue as they come.
Although a process with short burst time begins, the current process is removed or preempted from execution, and the job which is shorter is executed 1st.
SJF is frequently used for long term scheduling.
It reduces the average waiting time over FIFO (First in First Out) algorithm.
In SJF scheduling, Job completion time must be known earlier, but it is hard to predict.
SJF can’t be implemented for CPU scheduling for the short term. It is because there is no specific method to predict the length of the upcoming CPU burst.
Metadata(Ignore)
#Shortest Job First #(SJF) #Preemptive #Non-Preemptive #Scheduling #BurstTime
#smallest #averagewaitingtime #operatingsystem #operatingsysteminenglish