操作系统--高响应比调度算法和时间片轮转算法

本文深入探讨了操作系统中的两种进程调度算法:高响应比优先算法和时间片轮转法。通过详细解析算法原理,帮助读者理解如何在不同场景下选择合适的调度策略,以提高系统的响应效率。
摘要由CSDN通过智能技术生成

代码如下:

"""时间片轮转和高响应比优先算法"""
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(&
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值