Home » Operating Systems

SRTF with processes contains CPU and IO Time

In this article, we are going to study the SRTF with processes that contain Process CPU and IO Time.
Submitted by Monika Jha, on November 26, 2019

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)
P00(4,2,3)
P10(5,3,1)
P22(3,1,2)
P35(3,4,5)

The Gantt chart of the system according to SRTF scheduling will be prepared as follows,

SRTF with processes

Gantt chart

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.
ADVERTISEMENT
ADVERTISEMENT




Comments and Discussions!




Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.