Advertisement
JUN7

Fifo

Jan 6th, 2021
992
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.20 KB | None | 0 0
  1. def findWaitingTime(processes, n, bt, wt, quantum):
  2.     wt[0] = 0
  3.     for i in range(1, n ):
  4.         wt[i] = bt[i - 1] + wt[i - 1] + quantum
  5. def findTurnAroundTime(processes, n, bt, wt, tat):
  6.     for i in range(n):
  7.         tat[i] = bt[i] + wt[i]
  8. def findavgTime( processes, n, bt, quantum):
  9.     wt = [0] * n
  10.     tat = [0] * n
  11.     total_wt = 0
  12.     total_tat = 0
  13.     print ("Contoh  First Come First Serve ")
  14.     print ("Waiting Time = Turn Around Time - Burst Time ")
  15.     findWaitingTime(processes, n, bt, wt, quantum)
  16.     findTurnAroundTime(processes, n, bt, wt, tat)
  17.     print( "Processes Burst time " +
  18.                 " Waiting time " +
  19.                 " Turn around time")
  20.     for i in range(n):
  21.         total_wt = total_wt + wt[i]
  22.         total_tat = total_tat + tat[i]
  23.         print(" " + str(i + 1) + "\t\t" +
  24.                     str(bt[i]) + "\t " +
  25.                     str(wt[i]) + "\t\t " +
  26.                     str(tat[i]))
  27.     print ("quantum time = ", quantum)
  28.     print( "Average waiting time = "+ str(total_wt / n))
  29.     print("Average turn around time = "+ str(total_tat / n))
  30. if __name__ =="__main__":
  31.     processes = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
  32.     n = len(processes)
  33.     burst_time = [48, 35, 48*48, 15, 20, 48+48, 5, 48+14, (48+(2*48))-3, 12]
  34.     quantum = 4;
  35.     findavgTime(processes, n, burst_time,quantum)
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement