Home »
Operating System
SRTF with Processes contains CPU and IO Time
In this tutorial, we will learn about the SRTF with processes contains CPU and IO Time.
By Monika Jha Last updated : May 08, 2023
SRTF with Processes contains CPU and IO Time
Any process might need some IO operation or some resources to complete its execution. We were assuming the CPU bound jobs only(). However, the process might need some IO operation also or some resources to complete its execution.
By this example, we will be considering, the IO-bound jobs or processes.
In the example, we are taking four jobs with process ID P0, P1, P2, and P3 along with their arrival time, and the CPU burst time.
Process Id |
Arrival time |
(Burst time, IO Burst Time, Burst Time) |
P0 | 0 | (4,2,3) |
P1 | 0 | (5,3,1) |
P2 | 2 | (3,1,2) |
P3 | 5 | (3,4,5) |
Gantt chart
The Gantt chart of the system according to SRTF scheduling will be prepared as follows,
Gantt Chart Explanation
- According to the SRTF algorithm, the process with the shortest burst time will be scheduled on the CPU. Here, at time 0, the process P0 and P1 arrives. So these processes are in the ready queue. CPU burst time of process P1 is less than P0, so P1 will be scheduled on the CPU and it is in running state.
- From time 0 to 2, P1 is executing and at time 2, the process P2 arrived with the total CPU burst time of 5 units. Since no other process has the shortest burst time than the P1 so it will continue its execution.
- At time 5 after a total 5 units of execution, process P1 will change its state from running to waiting and at this time process P3 arrived with the total CPU burst time 8 units but P2 has the shortest burst time. From time 5 to 8, P2 is in the running state.
- At time 8, P1 will change its state from waiting to ready and at this time P1 has the shortest burst time of 1 unit. So, it will complete its execution.
- At time 9, P0 will change its state from ready to running and after 1 unit of execution P2 will execute with shortest burst time with 7 units.
- After 1 unit of execution, P2 will change its state from waiting to ready. At time 10, P2 will get execute from time 10 to 12.
- At time 12, P0 will get the processor and executes for 3 units of time and changes its state from running to waiting.
- At time 15, P3 will get scheduled for 2 units of time and at time 17, P0 will change its state from waiting to ready and to running with shortest CPU burst time of 3 units.
- At time 20, no other process is available other than P3 so P3 will get executed. Since P3 is an IO bound process so after 1 unit of execution it will change its state from running to waiting. At this time CPU is idle.
- At time 25, P3 will get execute hence no preemption will be done and it will be executed till the completion.