0
102kviews
Given the following table Draw gantt chart, calculate the average waiting time & average turn-around time if the processes are scheduled using:

Draw gantt chart, calculate the average waiting time & average turn-around time if the processes are scheduled using: FCFS algorithm SJF algorithm (preemptive)

5
12kviews

Turn Around Time = Process Completion Time – Process Arrival Time

Waiting time = Turn Around time – Burst time

First Come First Serve (FCFS) Scheduling

Process Arrival Time Burst Time Completion Time Turn Around Time Waiting Time
P1 0 6 6 6 – 0 = 6 6 – 6 = 0
P2 1 2 8 8 – 1 = 7 7 – 2 = 5
P3 2 5 13 13 – 2 = 11 11 – 5 = 6
P4 3 6 19 19 – 3 = 16 16 – 6 = 10
P5 7 1 20 20 – 7 = 13 13 – 1 = 12

Average Turn Around Time = (6 + 7 + 11 + 16 + 13)/5 = 10.6 ms

Average Waiting time = (0 + 5 + 6 + 10 +12)/5 = 6.6 ms

Shortest Job First SJF (Non-Pre-emptive) Scheduling

• In SJF Scheduling process with small burst time executed first.
• But, in Non-Pre-emptive SJF, once CPU cycle allocated to process, the process holds it till it terminated or reaches a waiting state.
• Non Pre-emptive SJF does not interrupt a process running in the middle of the execution. Instead, it waits until process completes execution and then allocates another process with small CPU burst time if arrived during execution of previous processes.
• Therefore, the processes executed in following sequence in SJF (Non-Pre-emptive) Scheduling.

Process Arrival Time Burst Time Completion Time Turn Around Time Waiting Time
P1 0 6 6 6 – 0 = 6 6 – 6 = 0
P2 1 2 8 8 – 1 = 7 7 – 2 = 5
P5 7 1 9 9 – 7 = 2 2 – 1 = 1
P3 2 5 14 14 – 2 = 12 12 – 5 = 7
P4 3 6 20 20 – 3 = 17 17 – 6 = 11

Average Turn Around Time = (6 + 7 + 2 + 12 + 17)/5 = 8.8 ms

Average Waiting time = (0 + 5 + 1 + 7 + 11)/5 = 4.8 ms

2
4.4kviews

FCFS algorithm
Gantt Chart

calculate the average waiting time & average turn-around time
Average turn-around time
= (6+7+11+16+13)/5
= 53/5
= 10.6
Average turn-around time = 10.6

Average waiting time
= (0+5+6+10+12)/5
=(33)/5
=6.6
Average waiting time =6.6

SJF algorithm (non-preemptive)
Gantt Chart
calculate the average waiting time & average turn-around time

Average turn-around time
= (6+7+2+12+17)/5
= 44/5
= 8.8
Average turn-around time = 8.8

Average waiting time
= (0+5+1+7+11)/5
=(24)/5
=4.8
Average waiting time =4.8