SJF scheduling

Shortest-Job-First(SJF) Scheduling

  • Best approach to minimize waiting time.
  • Actual time taken by the process is already known to processor.
  • Impossible to implement.
  • example:-

Shortest-Job-First(SJF) Scheduling

 

In Preemptive Shortest Job First Scheduling, jobs are put into ready queue as they arrive, but as a process with short burst time arrives, the existing process is preempted.

 

Contributor's Info

Created: Edited:
0Comment
Shortest Job Remaining Time First

Shortest Remaining Time First(SRTF) algorithm: This is preemptive version of shortest job first algorithm.  It’s minimize average turn arround time. If all processes are arrived at same time, then it works as SJF.

Example: Consider the following table:

Process no.

Arrival Time

Burst Time

P1

0

6

P2

2

1

P3

4

4

P4

5

3

Find the average waiting time and average turn arround time using SRTF(preemptive) algorithm?

Solution: Using SRTF(non-preemptive) algorithm, gantt chart is:

 

21.jpg

 

Therefore,  

Waiting Time

Turn around Time

Completion Time

Process No.

Arrival Time

Burst Time

7 - 6 = 1

7 - 0 = 7

7

P1

0

6

1 - 1 = 0

3 - 2 = 1

3

P2

2

1

10 - 4 = 5

14 - 4 = 10

14

P3

4

4

5 - 3 = 2

10 - 5= 5

10

P4

5

3

 

So,
Average Turn arround time  = (7 + 1 + 10 +5) / (4) = 5.75

Average Waiting time = (1 + 0 + 5 + 2) / (4) =2

 

Contributor's Info

Created: Edited:
1Comment
Sathya Dhinesh @sathyadhinesh
1 Jun 2019 11:25 pm
Superb sir