Open in App
Not now

# Shortest Job First CPU Scheduling with predicted burst time

• Difficulty Level : Medium
• Last Updated : 14 Mar, 2023

Prerequisite – CPU Scheduling, SJF – Set 1 (Non- preemptive), Set 2 (Preemptive)

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 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. There are two methods by which we can predict the burst time of the process :

1. Static method – We can predict the Burst-Time by two factors:

• 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 process(like scheduler, dispatcher, segmentation, fragmentation) are faster than User process( Gaming, application software). Burst-Time for any New O.S process can be predicted from any old O.S process of similar type and the same for the User process.

Simple average – Given n processes ( P1, P2… Pn)

`Î¤n+1 = 1/n(Î£i=1 to n ti)`
• Exponential average (Aging) –
`Î¤n+1 = Î±tn + (1 - Î±)Î¤n`
• where Î± = is smoothing factor and 0 <= Î± <= 1 , tn = actual burst time of nth process, Î¤n = predicted burst time of nth process. General term,
`Î±tn + (1 - Î±)Î±tn-1 + (1 - Î±)2Î±tn-2...+ (1 - Î±)jÎ±tn-j...+ (1 - Î±)n+1Î¤0 `
• Î¤0 is a constant or overall system average.
• If Î± = 0, Î¤n+1 = Î¤n i.e. no change in value of initial predicted burst time.
• If Î± = 1, Î¤n+1 = tn i.e. predicted Burst-Time of new process will always change according to actual      Burst-time of nth process.
• If Î± = 1/2, recent and past history are equally weighted.

Conclusion: SJF with predicted burst time is a practical and efficient CPU scheduling algorithm that can reduce the average waiting time of processes in the ready queue. By using historical data to predict the burst time of processes, it can make better scheduling decisions and adapt to changes in process behavior. However, the accuracy of the predicted burst time and the choice of the value of Î± need to be carefully considered to achieve optimal results.

My Personal Notes arrow_drop_up
Related Articles