0

I was going through the various scheduling algorithm and came across the shortest remaining time Job fist algorithm.

What I understand: Shortest remaining time job first algorithm is the preemptive version of the shortest time job algorithm. Here when a new process with lower burst time has arrived,it prempts the current process and the the new process is executed.

I came across a website while doing my study. The link for the site :

https://www.studytonight.com/operating-system/shortest-job-first Pre-emptive shortest job

What I Don't understand is that the author of the article says that when a process P4 with a CPU burst time of 2ms arrives and process P2 with a remaining burst time of 1ms is executed,P2 is pre-empted. Why is that so? Shouldn't P4 be put to the ready queue since it has more burst time than the remaining burst time of P2?

I understand the fact that burst times are compared and in this way the cpu burst time of P2 is (3ms) more than the CPU burst time of p4(2ms).But since 2 burst time have already been executed, the remaining burst time of p2 is less than that of p4.Why is it preempted?

E_net4
  • 27,810
  • 13
  • 101
  • 139
Savannah Madison
  • 575
  • 3
  • 8
  • 17
  • I have not seen or used a batch system for decades. Why are these kinds of questions asked? Is there some bastion of IBM mainframes and VAX hiding somewhere? – Martin James Feb 01 '21 at 08:06
  • 1
    I agree with you that the author of the article is mistaken in saying that P4 preempts P2. The author correctly states that P2 has 1ms left when P4 arrives with a 2ms burst time. So P2 should continue to completion before P4 starts. That would reduce the average waiting time, since the `(5-3)` term (P2 waiting for P4) would become `(4-3)` with P4 waiting for P2. – user3386109 Feb 01 '21 at 08:23
  • @user3386109 Thank you for the clarification. This was bugging me since morning and I wanted to get it clarified. – Savannah Madison Feb 01 '21 at 08:39

0 Answers0