Page 140 - PowerPoint Presentation
P. 140
CAVITE STATE UNIVERSITY
T3 CAMPUS
Department of Information Technology ITEC 55 – Platform Technologies
Average Turnaround Time is: Average Waiting Time is:
(2+7+10+18+29) / 5 = 13.2 ms (milliseconds) (0+1+6+9+17) / 5 = 6.6 ms
Another Example
Here’s another example, let’s say that there are gaps in the process, and the CPU
cannot schedule all the process continuously. For example, there are gaps in the Arrival Time
of the process.
Completion Turnaround Waiting
Process ID Arrival Time Burst Time
Time Time Time
A 0 2 2 2 0
B 3 1 4 1 0
C 5 6 11 6 0
A B C
0 2 3 4 5 11
Gannt Chart
Average Turnaround Time is: Average Waiting Time is:
(2+1+6) / 3 = 3 ms (2+1+6) / 3 = 3 ms
Shortest Job First (SJF) Scheduling
In FCFS, we are scheduling the process according to their arrival time. However, SJF
scheduling algorithm schedules the processes according to their burst time.
In SJF scheduling, the process with the lowest burst time among the list of available
processes in the ready queue is going to be scheduled next.
It is a non-preemptive scheduling algorithm wherein the process with the shortest CPU
burst time is the one that will be executed first, but if two or more processes have the same
CPU burst time, the FCFS algorithm may be used.
Let’s have an example, there are five process named as A, B, C, D and E. Their arrival
time and burst time are given in the table below.
To calculate the completion time, turnaround time, waiting time, average waiting time
and average turnaround time, use the following formula:
Completion Time = Total Amount of time spent by the process
Turnaround Time = Completion Time – Arrival Time
Waiting Time = Turnaround Time – Burst Time
Average Turnaround Time = Sum of Turnaround Tome / No. of Process
Average Waiting Time = Sum of Waiting Time / No. of Process
Completion Turnaround Waiting
Process ID Arrival Time Burst Time
Time Time Time
A 1 7
B 3 3
C 6 2
D 7 10
E 9 8
Since there’s no process arrives at time 0, there will be an empty slot in the Gantt Chart
from time 0 to 1 (the time at which the first process arrives).
According to the algorithm, the OS schedules the process which is having the lowest
burst time among the available process in the “ready” queue. And till now, we have only one
process in the ready queue hence the scheduler will schedule this to the processor no matter
Page | 20