Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def findWaitingTime(processes, n, bt, wt, quantum):
- wt[0] = 0
- for i in range(1, n ):
- wt[i] = bt[i - 1] + wt[i - 1] + quantum
- def findTurnAroundTime(processes, n, bt, wt, tat):
- for i in range(n):
- tat[i] = bt[i] + wt[i]
- def findavgTime( processes, n, bt, quantum):
- wt = [0] * n
- tat = [0] * n
- total_wt = 0
- total_tat = 0
- print ("Contoh First Come First Serve ")
- print ("Waiting Time = Turn Around Time - Burst Time ")
- findWaitingTime(processes, n, bt, wt, quantum)
- findTurnAroundTime(processes, n, bt, wt, tat)
- print( "Processes Burst time " +
- " Waiting time " +
- " Turn around time")
- for i in range(n):
- total_wt = total_wt + wt[i]
- total_tat = total_tat + tat[i]
- print(" " + str(i + 1) + "\t\t" +
- str(bt[i]) + "\t " +
- str(wt[i]) + "\t\t " +
- str(tat[i]))
- print ("quantum time = ", quantum)
- print( "Average waiting time = "+ str(total_wt / n))
- print("Average turn around time = "+ str(total_tat / n))
- if __name__ =="__main__":
- processes = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
- n = len(processes)
- burst_time = [48, 35, 48*48, 15, 20, 48+48, 5, 48+14, (48+(2*48))-3, 12]
- quantum = 4;
- findavgTime(processes, n, burst_time,quantum)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement