在 CPU 调度中,我们经常需要借助 Arrival、Burst 和 Completion Time 来找到平均 Turnaround 和 Waiting Time。让我们简要介绍一下它们:
周转时间(TAT):
- 它是从流程提交到流程完成的时间间隔。
- b/w完成时间和到达时间的差异称为周转时间。
完成时间 (CT):这是进程完成执行的时间。
到达时间(AT):这是进程到达就绪状态的时间。
TAT = CT - AT
等待时间(WT):
- 进程在就绪队列中等待获取 CPU 所花费的时间。
- b/w周转时间和突发时间的时间差称为等待时间。
突发时间(BT):这是进程执行所需的时间。
WT = TAT - BT
现在有了等待时间和突发时间,我们还可以通过以下方式计算周转时间:
TAT = BT + WT
例子:
Process | Burst Time (in sec.) |
---|---|
P1 | 24 |
P2 | 3 |
P3 | 4 |
解决方案:
Avg. TAT = (24 + 27 + 31) / 3 = 27.33 sec
Avg. WT = (0 + 24 + 27) / 3 = 17.0 sec
让我们看看周转时间和等待时间之间的区别:
S.No. | Turn Around Time | Waiting Time |
---|---|---|
1. | The time since the process entered into ready queue for execution till the process completed it’s execution. | The time process spent in the ready queue and for I/O completion. |
2. | Different CPU Scheduling algorithms produce different TAT for the same set of processes. | CPU Scheduling Algorithm doesn’t affect the amount of time during which a process executes or does I/O but only the amount of time that a process spends waiting in the ready queue. |
3. | The turnaround time is generally limited by the speed of the output device. | Waiting time has no such major effect. |