Shortest Job First CPU Scheduling with Predicted Burst Time (original) (raw)

Last Updated : 22 May, 2025

**Shortest Job First (SJF) is an optimal scheduling algorithm as it gives maximum Throughput and minimum average waiting time (WT) and turnaround time (TAT) but it is not practically implementable because the burst time of a process can't be predicted in advance.

We may not know the length of the next CPU burst but we may be able to predict its value. We expect the next CPU burst will be similar in length to the previous ones. By computing an approximation of the length of the next CPU burst, we can pick the process with the shortest predicted CPU burst.

SJF is a CPU scheduling algorithm that selects the process with the smallest next CPU burst time. Since actual burst times are not known in advance, we predict them using past behavior.

Methods to Predict Burst Time

There are two methods by which we can predict the burst time of the process:

predicive-burst

Methods To Predict Burst time

**Static Method

We can predict the burst time by two factors using the static method:

**Process size: Let's say we have Process Pold having size 200 KB which is already executed and its Burst-time is 20 Units of time, now let us say we have a New Process Pnew having size 201 KB which is yet to be executed.

We take the Burst Time of the already executed process Pold which is almost of the same size as that of the New process as the Burst Time of the New Process Pnew.

**Process type: We can predict burst time depending on the Type of Process.

Operating System processes (like scheduler, dispatcher, segmentation, and fragmentation) are faster than User processes (Gaming, application software). Burst Time for any New OS process can be predicted from any old OS process of similar type and the same for the User process.

Dynamic Technique

Simple average: Given n processes ( P1, P2... Pn)

Τn+1 = (Σi=1 to n ti).1/n

**Exponential average (Aging):

Τn+1 = αtn + (1 - α)Τn

αtn + (1 - α)αtn-1 + (1 - α)2αtn-2...+ (1 - α)jαtn-j...+ (1 - α)n+1Τ0

**How SJF with Prediction Works

**Example :

Process Last Actual Burst (tn) Last Predicted (Τn ) New Predicted (Τn+1 = αtn + (1 - α)Τn)
P1 6 5 0.5⋅6 + 0.5⋅5 = 5.5
P2 2 3 0.5⋅2 + 0.5⋅3 = 2.5

SJF chooses P2 since ​Τn+1 = 2.5 < 5.5 (P1).

**Additional Considerations for SJF Scheduling Algorithm

**Advantages

**Disadvantages