代码如下:
"""时间片轮转和高响应比优先算法"""
import random
from functools import reduce
class Job(object):
def __init__(self, name):
self.name = name
self.next = None
Job_Num = 5
ArrivalTime = [0 for _ in range(Job_Num)]
ServiceTime = [0 for _ in range(Job_Num)]
PServiceTime = [0 for _ in range(Job_Num)]
FinishTime = [0 for _ in range(Job_Num)]
WholeTime = [0 for _ in range(Job_Num)]
WeightWholeTime = [0 for _ in range(Job_Num)]
AverageWT_RR, AverageWWT_RR = 0, 0
AverageWT_PJF, AverageWWT_PJF = 0, 0
Finished = [False for _ in range(Job_Num)]
Job_Set = []
Job_Queue = []
def initial():
"""初始化"""
global ArrivalTime, ServiceTime, Job_Set
ArrivalTime = random.sample(range(Job_Num), Job_Num)
ServiceTime = random.sample(range(1, 26), Job_Num)
print('请输入{}个作业的名字'.format(Job_Num))
job = Job(&