How Does the SCAN-EDF Algorithm Work?
Let there be a total ‘T’ number of tasks.
Each task ‘ Ti ‘ has a corresponding deadline ‘ Di ‘ and a cylinder ‘ Ci ‘.
SCAN-EDF algorithm starts by performing modifications on the deadlines of all the tasks.
The modification is done as follows:
Di = Di + F( Ci )
Here the function ‘ F ‘ is usually taken as
F( Ci ) = ( Ci/Cmax ) – 1
Where,
- Ci – Cylinder of the task Ti
- Cmax – Cylinder of maximum value or any other suitable large value
Applying this modification causes a slight disturbance in the deadline values.
Note that any deadline Di > Dj must remain Di > Dj the after applying the modification.
Let us now apply the SCAN-EDF algorithm to the below situation. The initial position of the head is at ‘ 50 ‘.
Task |
Deadline |
Cylinder |
---|---|---|
T1 |
200 |
183 |
T2 |
200 |
25 |
T3 |
200 |
150 |
T4 |
300 |
190 |
Step 1: Apply modification to the deadline of all the tasks.
D1 = D1 + F( 183 ) = D1 + (183/190) – 1 = 200 + (183/190) – 1 = 199.96
D2 = D2 + F( 25 ) = D2 + (25/190) – 1 = 200 + (25/190) – 1 = 199.13
D3 = D3 + F( 150 ) = D3 + (150/190) – 1 = 200 + (150/190) – 1 = 199.79
D4 = D4 + F( 190) = D3 + (190/190) – 1 = 300 + 1 – 1 = 300
Step 2: Now apply the EDF algorithm w.r.t the above modified deadlines. The sequence of execution is going to be
T2→T3→T1→T4
The total number of head movements = (50 – 25) + (190 – 25) = 190
Thus it is clear that this algorithm overcomes the limitations of the EDF algorithm in situation where tasks with similar deadlines occur.
Note:
1) The SCAN-EDF algorithm works only in case of similar deadlines.
2) In all other cases its result is the same as the EDF algorithm.
SCAN – EDF Scheduling in OS
SCAN-EDF is a disk scheduling algorithm that is the same as the EDF algorithm but utilizes the seek optimization technique of the ‘SCAN’ algorithm when similar deadlines occur.
It is a hybrid algorithm. To understand the importance of this algorithm, let us first look at the drawbacks of strictly following the Earliest Deadline First (EDF) algorithm.
Consider the following situation where we have a few tasks with similar deadlines.
Task |
Deadline |
Cylinder |
---|---|---|
T1 |
200 |
183 |
T2 |
200 |
25 |
T3 |
200 |
150 |
T4 |
300 |
190 |
Let us apply only the EDF algorithm.
The starting position of the read-write head is ’50.
Tie between the tasks with the same deadline can be broken by making any random selection. Thus the order of execution can be
T1 → T2 → T3 → T4
The total number of head movements = (183-50) + (183-25) + (150-25) + (190-150) = 456
Strictly following the EDF algorithm can cause wild to and fro motion of the disk head, resulting in huge seek time values.
We can see that there can be a better approach to handling situations where tasks with similar deadlines are released. Thus some modification is needed in the EDF algorithm.