Computer Science Engineering (CSE) Exam  >  Computer Science Engineering (CSE) Notes  >  Operating System  >  Shortest Remaining Time First (SRTF) CPU Scheduling Algorithm

Shortest Remaining Time First (SRTF) CPU Scheduling Algorithm | Operating System - Computer Science Engineering (CSE) PDF Download

Introduction

This Algorithm is the preemptive version of SJF scheduling. In SRTF, the execution of the process can be stopped after certain amount of time. At the arrival of every process, the short term scheduler schedules the process with the least remaining burst time among the list of available processes and the running process.
Once all the processes are available in the ready queue, No preemption will be done and the algorithm will work as SJF scheduling. The context of the process is saved in the Process Control Block when the process is removed from the execution and the next process is scheduled. This PCB is accessed on the next execution of this process.

Example
In this Example, there are five jobs P1, P2, P3, P4, P5 and P6. Their arrival time and burst time are given below in the table.
Shortest Remaining Time First (SRTF) CPU Scheduling Algorithm | Operating System - Computer Science Engineering (CSE)Shortest Remaining Time First (SRTF) CPU Scheduling Algorithm | Operating System - Computer Science Engineering (CSE)Avg Waiting Time = 24/6

The Gantt chart is prepared according to the arrival and burst time given in the table.

  • Since, at time 0, the only available process is P1 with CPU burst time 8. This is the only available process in the list therefore it is scheduled.
  • The next process arrives at time unit 1. Since the algorithm we are using is SRTF which is a preemptive one, the current execution is stopped and the scheduler checks for the process with the least burst time.
    Till now, there are two processes available in the ready queue. The OS has executed P1 for one unit of time till now; the remaining burst time of P1 is 7 units. The burst time of Process P2 is 4 units. Hence Process P2 is scheduled on the CPU according to the algorithm.
  • The next process P3 arrives at time unit 2. At this time, the execution of process P3 is stopped and the process with the least remaining burst time is searched. Since the process P3 has 2 unit of burst time hence it will be given priority over others.
  • The Next Process P4 arrives at time unit 3. At this arrival, the scheduler will stop the execution of P4 and check which process is having least burst time among the available processes (P1, P2, P3 and P4). P1 and P2 are having the remaining burst time 7 units and 3 units respectively.
    P3 and P4 are having the remaining burst time 1 unit each. Since, both are equal hence the scheduling will be done according to their arrival time. P3 arrives earlier than P4 and therefore it will be scheduled again.
  • The Next Process P5 arrives at time unit 4. Till this time, the Process P3 has completed its execution and it is no more in the list. The scheduler will compare the remaining burst time of all the available processes. Since the burst time of process P4 is 1 which is least among all hence this will be scheduled.
  • The Next Process P6 arrives at time unit 5, till this time, the Process P4 has completed its execution. We have 4 available processes till now, that are P1 (7), P2 (3), P5 (3) and P6 (2). The Burst time of P6 is the least among all hence P6 is scheduled. Since, now, all the processes are available hence the algorithm will now work same as SJF. P6 will be executed till its completion and then the process with the least remaining time will be scheduled.

Once all the processes arrive, No preemption is done and the algorithm will work as SJF.

The document Shortest Remaining Time First (SRTF) CPU Scheduling Algorithm | Operating System - Computer Science Engineering (CSE) is a part of the Computer Science Engineering (CSE) Course Operating System.
All you need of Computer Science Engineering (CSE) at this link: Computer Science Engineering (CSE)
10 videos|99 docs|33 tests

Top Courses for Computer Science Engineering (CSE)

10 videos|99 docs|33 tests
Download as PDF
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev
Related Searches

shortcuts and tricks

,

practice quizzes

,

video lectures

,

MCQs

,

Summary

,

Exam

,

Shortest Remaining Time First (SRTF) CPU Scheduling Algorithm | Operating System - Computer Science Engineering (CSE)

,

Semester Notes

,

pdf

,

Shortest Remaining Time First (SRTF) CPU Scheduling Algorithm | Operating System - Computer Science Engineering (CSE)

,

study material

,

Objective type Questions

,

Sample Paper

,

mock tests for examination

,

Shortest Remaining Time First (SRTF) CPU Scheduling Algorithm | Operating System - Computer Science Engineering (CSE)

,

Free

,

Important questions

,

Previous Year Questions with Solutions

,

Extra Questions

,

Viva Questions

,

ppt

,

past year papers

;