This algorithm requires advanced concept and knowledge of CPU time required to process the job in an interactive system, and hence can’t be implemented there. But, in a batch system where it is desirable to give preference to short jobs, SRT algorithm is used.
However, SRT involves more overheads than SJN, as the OS is required to frequently monitor the CPU time of the jobs in the READY queue and perform context switching.
As illustrated above, for the same set of jobs, SRT algorithm is faster in execution than SJN algorithm. But, here the overhead charges, i.e., time required for context switching has been ignored. When a job is preempted, all of it’s processing information must be saved in it’s PCB for later when it is to be continued, and the contents of the PCB of the other job to which the OS is switching are loaded into the registers in the memory. This is known as Context Switching.
SRTF algorithm makes the processing of the jobs faster than SJN algorithm, given it’s overhead charges are not counted.
The context switch is done a lot more times in SRTF than in SJN, and consumes CPU’s valuable time for processing. This adds up to it’s processing time and diminishes it’s advantage of fast processing.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Longest Remaining Time First (LRTF) CPU Scheduling Algorithm
- Longest Remaining Time First (LRTF) CPU Scheduling Program
- Least Slack Time (LST) scheduling Algorithm in real-time systems
- Shortest Job First (or SJF) CPU Scheduling Non-preemptive algorithm using Segment Tree
- Shortest Job First CPU Scheduling with predicted burst time
- Algorithm for Dynamic Time out timer Calculation
- Program for Banker's Algorithm | Set 1 (Safety Algorithm)
- Difference between Seek Time and Transfer Time in Disk Scheduling
- Difference between Load Time and Execution Time address binding
- Difference between Compile Time and Execution Time address binding
- Difference between Compile Time and Load Time address Binding
- Difference between Turn Around Time (TAT) and Waiting Time (WT) in CPU Scheduling
- Difference between Arrival Time and Burst Time in CPU Scheduling
- Difference between Time Sharing OS and Real-Time OS
- Clairvoyant Shortest Job first (SJF)
- Difference between Seek Time and Disk Access Time in Disk Scheduling
- Difference between Hard real time and Soft real time system
- Difference between Transfer Time and Disk Access Time in Disk Scheduling
- Open shortest path first (OSPF) - Set 2
- Program for Shortest Job First (SJF) scheduling | Set 2 (Preemptive)
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.