SJF Scheduling-
Before you go through this article, make sure that you have gone through the previous article on SJF Scheduling.
In SJF Scheduling,
- Out of all the available processes, CPU is assigned to the process having smallest burst time.
- The main drawback of SJF Scheduling is that it can not be implemented practically.
- This is because burst time of the processes can not be known in advance.
In this article, we will discuss techniques to predict burst time.
Techniques to Predict Burst Time-
There are several techniques which try to predict the burst time for the processes so that the algorithm can be implemented.
These techniques are-
Static Techniques-
There are two static techniques-
- Based on process size
- Based on process type
1. Based on Process Size-
- This technique predicts the burst time for a process based on its size.
- Burst time of the already executed process of similar size is taken as the burst time for the process to be executed.
Example-
- Consider a process of size 200 KB took 20 units of time to complete its execution.
- Then, burst time for any future process having size around 200 KB can be taken as 20 units.
NOTE
|
2. Based on Process Type-
- This technique predicts the burst time for a process based on its type.
- The following figure shows the burst time assumed for several kinds of processes.
Dynamic Techniques-
There are two dynamic techniques-
- Based on simple averaging
- Based on exponential averaging
1. Based on Simple Averaging-
- Burst time for the process to be executed is taken as the average of all the processes that are executed till now.
- Given n processes P1, P2, … , Pn and burst time of each process Pi as ti, then predicted burst time for process Pn+1 is given as-
2. Based on Exponential Averaging-
- Given n processes P1, P2, … , Pn and burst time of each process Pi as ti. Then, predicted burst time for process Pn+1 is given as-
where-
- α is called smoothening factor (0<= α <=1)
- tn = actual burst time of process Pn
- Tn = Predicted burst time for process Pn
PRACTICE PROBLEM BASED ON PREDICTING BURST TIME-
Problem-
Calculate the predicted burst time using exponential averaging for the fifth process if the predicted burst time for the first process is 10 units and actual burst time of the first four processes is 4, 8, 6 and 7 units respectively. Given α = 0.5.
Solution-
Given-
- Predicted burst time for 1st process = 10 units
- Actual burst time of the first four processes = 4, 8, 6, 7
- α = 0.5
Predicted Burst Time for 2nd Process-
Predicted burst time for 2nd process
= α x Actual burst time of 1st process + (1-α) x Predicted burst time for 1st process
= 0.5 x 4 + 0.5 x 10
= 2 + 5
= 7 units
Predicted Burst Time for 3rd Process-
Predicted burst time for 3rd process
= α x Actual burst time of 2nd process + (1-α) x Predicted burst time for 2nd process
= 0.5 x 8 + 0.5 x 7
= 4 + 3.5
= 7.5 units
Predicted Burst Time for 4th Process-
Predicted burst time for 4th process
= α x Actual burst time of 3rd process + (1-α) x Predicted burst time for 3rd process
= 0.5 x 6 + 0.5 x 7.5
= 3 + 3.75
= 6.75 units
Predicted Burst Time for 5th Process-
Predicted burst time for 5th process
= α x Actual burst time of 4th process + (1-α) x Predicted burst time for 4th process
= 0.5 x 7 + 0.5 x 6.75
= 3.5 + 3.375
= 6.875 units
To gain better understanding about predicting burst time,
Next Article- LJF Scheduling | LRTF Scheduling
Get more notes and other study material of Operating System.
Watch video lectures by visiting our YouTube channel LearnVidFun.