进程调度:一个例子区分响应时间、周转时间和等待时间

本文介绍了操作系统中关于进程调度的重要概念,如到达时间、执行时间、响应时间、周转时间和等待时间,并通过一个圆 robin 调度算法的例子详细解析了这些指标的计算。在例子中,展示了不同进程在特定时间片调度下的响应时间、周转时间和等待时间的计算过程,帮助读者深入理解这些关键性能参数。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

参考链接

arrival time:the time when a process enters into the ready state and is ready for its execution.(进程进入就绪态的时刻)
burst time: the total time taken by the process for its execution on the CPU(进程在CPU上执行花费的时间,不包括I/O时间)

响应时间(Response time):Response time is the time spent when the process is in the ready state and gets the CPU for the first time. (自进程就绪至进程第一次获得CPU响应的时间)

Response time = Time at which the process gets the CPU for the first time - Arrival time

周转时间(turnarouad time):Turnaround time is the total amount of time spent by the process from coming in the ready state for the first time to its completion.(进程从第一次进入就绪状态到完成所花费的总时间。)

Turnaround time = Exit time - Arrival time

等待时间(Waiting time):Waiting time is the total time spent by the process in the ready state waiting for CPU.(进程处于就绪状态等待CPU所花费的总时间)

Waiting time = Turnaround time - Burst time

例题:

Suppose round robin scheduler(时间片轮转调度算法) is used and the quantum is 2. Given the below 4 processes:
在这里插入图片描述
甘特图:
调度方式
补充一下就绪队列时刻表:(就绪队列队首的进程即为当前要运行的进程
在这里插入图片描述
:时刻2 :此时p1完成一个时间片,p2到来,先将新进程(p2)插入到就绪队列尾部,再将经过一个时间片后未执行完毕的p1插入到就绪队列尾部。

响应时间(Response time) : (第一次响应 - 到达时间)
P1: 0 - 0 = 0
P2: 2 - 2 = 0
P3: 6 - 3 = 3
P4: 12 - 9 = 3

周转时间(turnarouad time): (结束时刻 - 到达时间)
P1: 14 - 0 = 14
P2: 10 - 2 = 8
P3: 8 - 3 = 5
P4: 13 - 9 = 4

等待时间(Waiting time):(周转时间 - 运行时间)
P1: 14 - 7 = 7
P2: 8 - 4 = 4
P3: 5 - 2 = 3
P4: 4 - 1 = 3

扩展:

带权周转时间 = 周转时间/运行时间

评论 17
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值