2. Shortest Remaining Time (SRT)
Is the preemptive version of the SJN (Shortest
Job Next) algorithm. The processor is allocated
to the job closest to completion --- but even this
job can be preempted if the newer job in the
READY queue has a time to completion that’s
shorter.
3. This algorithm can be implemented in an interactive
system because it requires advance knowledge of
the CPU time required to finish each job. It is often
used in batch environments, when it is desirable to
give preference to short job; even though SRT
involves more overhead than SJN because the
operating system has to frequently monitor the CPU
time for all the jobs being swapped (switched) at
preemption time (not necessarily swapped out to the
disk although this might occur as well).
4. Example:
The example in Figure 1 shows how the SRT algorithm
works in four jobs that arrived in quick succession (one
CPU cycle part).
5. Figure 1. timeline for job sequence A, B,C,D using the preemptive SRT
algorithm. Each job is interrupted after one CPU cycle if another job is
waiting with less CPU time remaining
6. In this case, the turn around time is the completion time of each job
minus its arrival time:
Job A B C D
Turnaround 14 4 1 6
14+4+1+6
So the average turnaround time is:
4 = 6.25