# 轮转调度

轮转调度（round-robin scheduling）是一种抢占式调度方法：每个可运行任务获得处理器一段固定的最长时间，称为时间片（time quantum）；任务在时间片耗尽时若尚未完成，就被放到就绪队列的末尾，等待下一轮。它是标准的[分时](https://www.edgepedia.org/zh/time-sharing)策略：与先来先服务（FCFS）调度密切相关，但 CPU 突发受时间片限制，因此任何单个任务都无法无限期地占用处理器。<sup>[1](https://www.cs.uic.edu/~jbell/CourseNotes/OperatingSystems/6_CPU_Scheduling.html)</sup>

| 关键事实 | 细节 |
|---|---|
| 机制 | 每个任务最多运行一个时间片；若时间片计时器先到期，任务被移到循环就绪队列的末尾，调度器在其余所有进程都轮过一遍之后，再给第一个进程下一次机会<sup>[1](https://www.cs.uic.edu/~jbell/CourseNotes/OperatingSystems/6_CPU_Scheduling.html)</sup> |
| 抢占 | 在时间片到期前完成 CPU 突发的任务只是主动让出，与 FCFS 相同；只有长于时间片的任务才会被抢占<sup>[1](https://www.cs.uic.edu/~jbell/CourseNotes/OperatingSystems/6_CPU_Scheduling.html)</sup> |
| Linux 实时策略 | SCHED_RR 是对 SCHED_FIFO 的简单增强：FIFO 的一切规则都适用，只是每个线程最多只运行一个时间片，被抢占的线程在恢复时继续使用其时间片未用完的部分<sup>[2](https://man7.org/linux/man-pages/man7/sched.7.html)</sup> |
| 时间片查询 | 在 Linux 上，可用 sched_rr_get_interval(2) 查询 SCHED_RR 的时间片长度<sup>[2](https://man7.org/linux/man-pages/man7/sched.7.html)</sup> |
| 开销示例 | 上下文切换开销为 5 毫秒、时间片为 20 毫秒时，开销占 CPU 时间的 20%；时间片为 50 毫秒时降到约 10%<sup>[3](https://os.cs.luc.edu/scheduling.html)</sup> |
| 网络变体 | 差额轮转（DRR）为每条流保留亏空状态，使可变包长不致令轮转失去公平；基本 DRR 提供吞吐量公平，但不提供时延上界<sup>[4](https://web.stanford.edu/class/ee384x/EE384X/papers/DRR.pdf)</sup> |
| 无线结果 | 在一项 5G 毫米波 NS-3 研究中，对语音流量，RR 的吞吐量比比例公平高 3.65%，公平性指数相近，且在语音和视频两类流量上公平性指数都更好<sup>[5](https://univagora.ro/jour/index.php/ijccc/article/view/3570)</sup> |

## 工作原理

调度器把可运行任务维护在一个循环 FIFO 队列中。CPU 空闲时，它取出队首任务，并为时间片设置一个硬件计时器。如果任务在计时器触发前因 I/O 阻塞或终止，它就提前离开处理器，与 FCFS 下完全相同。如果计时器先到期，任务被抢占并重新排到队尾，于是 CPU 密集型任务在队列中轮转，每个任务获得大致相等的处理器时间份额。<sup>[1](https://www.cs.uic.edu/~jbell/CourseNotes/OperatingSystems/6_CPU_Scheduling.html)</sup><sup> • </sup><sup>[6](https://cseweb.ucsd.edu/classes/sp16/cse120-a/applications/ln/lecture5.html)</sup>

由于作业的任何特征都不影响其在队列中的位置，这一策略实现简单、在基本意义上公平，且不会饥饿：每个可运行任务最终都会轮到。代价是它忽略优先级、I/O 行为和截止时间，因此一个短的交互式作业可能排在许多其他任务的若干个时间片之后，平均等待时间通常高于最短作业优先策略。<sup>[6](https://cseweb.ucsd.edu/classes/sp16/cse120-a/applications/ln/lecture5.html)</sup><sup> • </sup><sup>[3](https://os.cs.luc.edu/scheduling.html)</sup>

## 时间片的选择

时间片是控制响应性与效率之间权衡的参数。时间片短，可运行任务轮到自己之前的等待时间就短，响应性更好；时间片长，系统花在上下文切换上的时间更少，效率更高。有五个可运行任务时，较短的时间片直接缩短了轮次之间的间隔。<sup>[3](https://os.cs.luc.edu/scheduling.html)</sup>

开销的算术很具体。若一次上下文切换耗时 5 毫秒、时间片为 20 毫秒，系统有 20% 的时间花在切换上；把时间片提高到 50 毫秒，这一比例降到约 10%。教科书的指导原则是：时间片必须远大于上下文切换时间，以避免过高的开销。<sup>[3](https://os.cs.luc.edu/scheduling.html)</sup><sup> • </sup><sup>[7](https://www.cs.csustan.edu/~john/Classes/CS3750/Notes/Chap05/05_CPU_Scheduling.html)</sup>

时间片还决定了算法在极限情况下的行为。若时间片相对于所有 CPU 突发都很大，轮转调度退化为 FCFS。若时间片非常小，每个进程获得 1/n 的处理器时间，系统趋近于处理器共享，即所有驻留作业以相等的 CPU 份额同时运行；在这一范围内，周转时间随时间片而变化。<sup>[1](https://www.cs.uic.edu/~jbell/CourseNotes/OperatingSystems/6_CPU_Scheduling.html)</sup>

## 排队论

轮转调度是 20 世纪 60 至 70 年代分时时代大量数学文献的研究对象。当时在普林斯顿大学（Princeton University）的 小 E. G. 科弗曼（Coffman） 于 1969 年定义并分析了轮转与前台-后台服务策略的马尔可夫排队模型，明确计入了程序换入换出处理器的交换或设置开销，并推导出队列长度概率与平均等待时间的生成函数。<sup>[8](https://onlinelibrary.wiley.com/doi/10.1002/nav.3800160203)</sup> 1971 年，东北大学（Tohoku University）的M. 坂田（Sakata）、S. 野口（Noguchi）和 J. 大泉（Oizumi）分析了三种轮转模型下的 M/G/1 排队——固定时间片、处理器共享（零时间片）和可变时间片——并给出了一种在带开销的任意处理时间分布下计算期望响应时间的方法。<sup>[9](https://pubsonline.informs.org/doi/abs/10.1287/opre.19.2.371)</sup> 加州大学洛杉矶分校（UCLA）的伦纳德·克莱因罗克（Leonard Kleinrock）研究了极限情形下的处理器共享模型，即系统中所有作业平等共享服务器，将其作为分时计算的理想化。<sup>[10](https://onlinelibrary.wiley.com/doi/abs/10.1002/net.3230010103)</sup>

## Linux 实时调度中的轮转

Linux 以 SCHED_RR 实时策略提供轮转调度。它被定义为对 SCHED_FIFO 的简单增强：FIFO 线程一直运行，直到因 I/O 阻塞、被更高优先级线程抢占或调用 sched_yield(2)；SCHED_RR 只增加了最大时间片，时间片用完后线程转到其优先级对应列表的末尾。被更高优先级线程抢占的 SCHED_RR 线程在恢复时使用其时间片未用完的剩余部分，而不是重新获得一个完整时间片。<sup>[2](https://man7.org/linux/man-pages/man7/sched.7.html)</sup>

由于 SCHED_FIFO、SCHED_RR 或 SCHED_DEADLINE 下的非阻塞死循环可能无限期地阻止所有其他线程使用 CPU，内核提供了保护措施：自 Linux 2.6.25 起，RLIMIT_RTTIME 资源限制为实时进程可消耗的 CPU 时间设了上限，而 /proc/sys/kernel/sched_rt_period_us 与 sched_rt_runtime_us 为非实时进程保留一份 CPU 时间，默认允许实时进程使用每 1,000,000 微秒中的 950,000 微秒，留下 5% 给普通工作。<sup>[2](https://man7.org/linux/man-pages/man7/sched.7.html)</sup> 红帽（Red Hat）的实时文档同样将 SCHED_RR 描述为轮转实时策略，并指出可用 sched_rr_get_interval() 读取进程的时间片长度。<sup>[11](https://docs.redhat.com/en/documentation/red_hat_enterprise_linux_for_real_time/9/pdf/understanding_rhel_for_real_time/Red_Hat_Enterprise_Linux_for_Real_Time-9-Understanding_RHEL_for_Real_Time-en-US.pdf)</sup>

## 数据包与网络调度

同样的轮转思想贯穿网络领域，只是服务单位是数据包而非时间片。当各条流使用不同包长时，朴素轮转并不公平，因为发送大包的流每一轮获得更多带宽。M. 什里达尔（Shreedhar）与乔治·瓦尔盖塞（Varghese）在《IEEE/ACM 网络汇刊》（IEEE/ACM Transactions on Networking）上描述的差额轮转（DRR）通过保留每条流的状态来解决这一问题，该状态以字节计量亏空，即累积的过往不公平；它保持每包 O(1) 的复杂度，也适用于服务无法再分割为更小单位的调度问题，如负载均衡和分布式队列。<sup>[4](https://web.stanford.edu/class/ee384x/EE384X/papers/DRR.pdf)</sup>

[DRR](https://www.edgepedia.org/zh/deficit-round-robin) 成为广泛部署的队列管理的构件。RFC 8290 标准化的 FQ-CoDel 调度器使用一种改进的、基于字节的 DRR，其中每个队列每次迭代最多可出队一个可配置字节配额的数据包，偏差以字节信用结转；它用两级轮转方案组织队列，把新队列与已形成持续积压的队列分开，Linux 实现中默认有 1024 个队列。<sup>[12](https://www.rfc-editor.org/info/rfc8290/)</sup> 研究仍在继续改进这一族算法：在 USENIX NSDI 2025 上提出的自时钟轮转调度（Self-Clocked Round-Robin Scheduling）是一种无参数变体，通过调整短小、时延敏感流的虚拟时间为其提供优先，在流公平性相同的情况下，与使用小时间片的 DRR 相比平均 CPU 开销降低 23%，与使用大时间片的 DRR 相比应用时延改善 71%。<sup>[13](https://www.usenix.org/conference/nsdi25/presentation/sharafzadeh)</sup>

## 无线与蜂窝调度

在蜂窝网络中，轮转调度作为面向公平的基线，用来与信道感知调度器比较。由于它分配资源时不考虑信道状况，它以平均用户吞吐量为代价最大化公平性，而最佳信道质量方案正好相反，比例公平调度则在两者之间取得平衡。<sup>[14](https://as-proceeding.com/index.php/icfar/article/download/148/100/231)</sup> 一项比较 RR 与比例公平的 5G 毫米波仿真研究发现：对语音流量，RR 的吞吐量高 3.65%，公平性指数相近；对视频，比例公平高 1.24%；而在两类流量上 RR 的公平性指数都更好。<sup>[5](https://univagora.ro/jour/index.php/ijccc/article/view/3570)</sup> 运用随机几何与排队论对小基站网络进行的理论分析发现，无论流量统计特性如何，轮转调度在平均时延上都优于随机调度，且在高负载下优势更明显；在相同的时延中断概率下，轮转调度可支持更多用户设备，使其成为物联网流量调度的候选方案。<sup>[15](https://arxiv.org/abs/1802.00917)</sup>

## 动态时间片变体

一大类研究致力于修改固定时间片，因为时间片的决定强烈影响平均等待时间、周转时间和上下文切换次数。已提出的算法根据就绪队列中等待的进程的突发时间来调整时间片：中位数-平均值轮转（MARR）算法根据进程突发时间的中位数和平均值设定动态时间片，据报告与另外四种调度算法相比降低了平均周转时间和等待时间。<sup>[16](https://www.sciencedirect.com/science/article/pii/S1110016822002599)</sup> 相关提案包括带重新调整的动态时间片、带到达时间的多动态时间片轮转，以及旨在最小化等待时间同时保持低上下文切换次数的可变时间片方案。<sup>[17](https://arxiv.org/abs/1103.3831)</sup><sup> • </sup><sup>[18](https://arxiv.org/abs/1109.3076)</sup><sup> • </sup><sup>[19](https://arxiv.org/abs/1003.5342)</sup>

## References

1. [CPU Scheduling, course notes on Silberschatz, Gagne, and Galvin, Operating System Concepts, 9th ed., ch. 6, University of Illinois at Chicago](https://www.cs.uic.edu/~jbell/CourseNotes/OperatingSystems/6_CPU_Scheduling.html)
2. [sched(7) - Linux manual page](https://man7.org/linux/man-pages/man7/sched.7.html)
3. [Process/Thread Scheduling, Introduction to Operating Systems: Principles and Practice, Loyola University Chicago](https://os.cs.luc.edu/scheduling.html)
4. [M. Shreedhar and George Varghese, Efficient Fair Queuing Using Deficit Round-Robin, IEEE/ACM Transactions on Networking](https://web.stanford.edu/class/ee384x/EE384X/papers/DRR.pdf)
5. [Doan Perdana, Aji Nur Sanyoto, Yoseph Gustommy Bisono, Performance Evaluation and Comparison of Scheduling Algorithms on 5G Networks using Network Simulator, International Journal of Computers Communications & Control](https://univagora.ro/jour/index.php/ijccc/article/view/3570)
6. [Lecture 5 (Scheduling), CSE 120, University of California San Diego](https://cseweb.ucsd.edu/classes/sp16/cse120-a/applications/ln/lecture5.html)
7. [Chapter 5: CPU Scheduling, notes on Silberschatz, Operating System Concepts, 10th ed., California State University Stanislaus](https://www.cs.csustan.edu/~john/Classes/CS3750/Notes/Chap05/05_CPU_Scheduling.html)
8. [E. G. Coffman Jr., Markov chain analyses of multiprogrammed computer systems, Naval Research Logistics Quarterly 16(2), 1969](https://onlinelibrary.wiley.com/doi/10.1002/nav.3800160203)
9. [M. Sakata, S. Noguchi, J. Oizumi, An Analysis of the M/G/1 Queue Under Round-Robin Scheduling, Operations Research 19(2), 1971](https://pubsonline.informs.org/doi/abs/10.1287/opre.19.2.371)
10. [L. Kleinrock, R. R. Muntz, E. Rodemich, The processor-sharing queueing model for time-shared systems with bulk arrivals, Networks, 1971](https://onlinelibrary.wiley.com/doi/abs/10.1002/net.3230010103)
11. [Red Hat Enterprise Linux for Real Time 9: Understanding RHEL for Real Time](https://docs.redhat.com/en/documentation/red_hat_enterprise_linux_for_real_time/9/pdf/understanding_rhel_for_real_time/Red_Hat_Enterprise_Linux_for_Real_Time-9-Understanding_RHEL_for_Real_Time-en-US.pdf)
12. [RFC 8290: The Flow Queue CoDel Packet Scheduler and Active Queue Management Algorithm, RFC Editor, January 2018](https://www.rfc-editor.org/info/rfc8290/)
13. [Erfan Sharafzadeh et al., Self-Clocked Round-Robin Packet Scheduling, USENIX NSDI 2025](https://www.usenix.org/conference/nsdi25/presentation/sharafzadeh)
14. [Comparative analysis of scheduling schemes for fairness and average user throughput, ICFAR proceedings](https://as-proceeding.com/index.php/icfar/article/download/148/100/231)
15. [Howard H. Yang, Ying Wang, Tony Q. S. Quek, Delay Analysis of Random Scheduling and Round Robin in Small Cell Networks, arXiv:1802.00917](https://arxiv.org/abs/1802.00917)
16. [A new median-average round Robin scheduling algorithm: An optimal approach for reducing turnaround and waiting time, Alexandria Engineering Journal / ScienceDirect](https://www.sciencedirect.com/science/article/pii/S1110016822002599)
17. [A New Proposed Dynamic Quantum with Re-Adjusted Round Robin Scheduling Algorithm and Its Performance Analysis, arXiv:1103.3831](https://arxiv.org/abs/1103.3831)
18. [Comparative performance analysis of multi dynamic time quantum Round Robin (MDTQRR) algorithm with arrival time, arXiv:1109.3076](https://arxiv.org/abs/1109.3076)
19. [Improving Waiting Time of Tasks Scheduled Under Preemptive Round Robin Using Changeable Time Quantum, arXiv:1003.5342](https://arxiv.org/abs/1003.5342)

---
*Initially written Sep 17, 2026 · Reviewed: Oct 15, 2026 · Edited: Oct 15, 2026 · Last review: Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 人工智能与数据 › 算法与计算方法 › 算法概述

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/round-robin-scheduling

English original: https://www.edgepedia.org/round-robin-scheduling
