-1
def Calc_AvgTime( process, n, bt):          # For calculating average time

    wt = [0] * n
    tat = [0] * n
    total_wt = 0
    total_tat = 0
    total_rd = 0

    Calc_waitingTime(process, n, bt, wt)
    Calc_TATime(process, n, bt, wt, tat)
    Calc_ResponseDelay(process, n, bt, tat, rd)

    print( " Process " + "   BT " + " WT " + " TAT " + " RD ")

    for i in range(n):
        total_wt = total_wt + wt[i]
        total_tat = total_tat + tat[i]
        total_rd = total_rd + rd[i]
        print(" " + str(i + 1) + " \t    " + str(bt[i]) + "   " + str(wt[i]) + "    " + str(tat[i]) + "   " + str(rd[i]))

    print("Average Waiting Time = "+ str(total_wt / n))
    print("Average Turn Around Time = "+ str(total_tat / n))
    print("Average Response Delay = "+ str(total_rd / n))

运行代码时会出现未定义的变量错误。以上部分是整个代码的一部分。

def Calc_ResponseDelay(process, n, bt, tat, rd):            # For calculating response delay

    for i in range(n):
        rd[i] = tat[i] / bt[i]

这是我编写的函数,用于查找 FCFS 问题中的相对延迟,以查找平均等待时间、周转时间和相对延迟。

4

0 回答 0