Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to calculate Average Waiting Time and average Turn-around time in SJF Scheduling?

Tags:

In SJF (Shortest Job First) Scheduling method.

enter image description here

How to calculate Average Waiting Time and average Turn-around time?

Is Gannt Chart correct ?

enter image description here

like image 886
Failed_Noob Avatar asked Mar 18 '12 13:03

Failed_Noob


2 Answers

Gantt chart is wrong... First process P3 has arrived so it will execute first. Since the burst time of P3 is 3sec after the completion of P3, processes P2,P4, and P5 has been arrived. Among P2,P4, and P5 the shortest burst time is 1sec for P2, so P2 will execute next. Then P4 and P5. At last P1 will be executed.

Gantt chart for this ques will be:

| P3 | P2 | P4 | P5 | P1 |  1    4    5    7   11   14 

Average waiting time=(0+2+2+3+3)/5=2

Average Turnaround time=(3+3+4+7+6)/5=4.6

like image 139
Hifzan Avatar answered Oct 24 '22 04:10

Hifzan


SJF are two type - i) non preemptive SJF ii)pre-emptive SJF

I have re-arranged the processes according to Arrival time. here is the non preemptive SJF

A.T= Arrival Time

B.T= Burst Time

C.T= Completion Time

T.T = Turn around Time = C.T - A.T

W.T = Waiting Time = T.T - B.T

enter image description here

Here is the preemptive SJF Note: each process will preempt at time a new process arrives.Then it will compare the burst times and will allocate the process which have shortest burst time. But if two process have same burst time then the process which came first that will be allocated first just like FCFS.

enter image description here

like image 37
Erfan Ahmed Avatar answered Oct 24 '22 06:10

Erfan Ahmed