Linux SCHED_OTHER、SCHED_FIFO 和 SCHED_RR - 差异

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9392415/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 04:44:43  来源:igfitidea点击:

Linux SCHED_OTHER, SCHED_FIFO and SCHED_RR - differences

linuxlinux-kernelschedulerschedulingcfs

提问by eve

Can someone explain the differences between SCHED_OTHER, SCHED_FIFO and SCHED_RR?

有人可以解释 SCHED_OTHER、SCHED_FIFO 和 SCHED_RR 之间的区别吗?

Thanks

谢谢

采纳答案by Claudio

SCHED_FIFO and SCHED_RR are so called "real-time" policies. They implement the fixed-priority real-time scheduling specified by the POSIX standard. Tasks with these policies preempt every other task, which can thus easily go into starvation (if they don't release the CPU).

SCHED_FIFO 和 SCHED_RR 是所谓的“实时”策略。它们实现了 POSIX 标准规定的固定优先级实时调度。具有这些策略的任务会抢占其他所有任务,因此很容易陷入饥饿状态(如果它们不释放 CPU)。

The difference between SCHED_FIFO and SCHED_RR is that among tasks with the same priority, SCHED_RR performs a round-robin with a certain timeslice; SCHED_FIFO, instead, needs the task to explicitly yield the processor.

SCHED_FIFO 和 SCHED_RR 的区别在于,在优先级相同的任务中,SCHED_RR 以一定的时间片进行循环;相反,SCHED_FIFO 需要任务显式让出处理器。

SCHED_OTHER is the common round-robin time-sharing scheduling policy that schedules a task for a certain timeslice depending on the other tasks running in the system.

SCHED_OTHER 是常见的循环分时调度策略,它根据系统中运行的其他任务将任务调度到某个时间片。

Update: since Linux 3.14, there is an additional policy called SCHED_DEADLINE. This policy implements the Constant Bandwidth Server (CBS) algorithm on top of Earliest Deadline Firstqueues. Each task under this policy is assigned a deadline, and the earliest-deadline task is executed. The best resource describing this algorithm is Deadline scheduling in the Linux kernel.

更新:从 Linux 3.14 开始,还有一个名为SCHED_DEADLINE的附加策略。此策略在最早截止日期优先队列之上实施恒定带宽服务器 (CBS) 算法。此策略下的每个任务都分配了一个截止日期,并执行最早截止日期的任务。描述此算法的最佳资源是Linux 内核中的 Deadline 调度

Update 2: since Linux 4.13, SCHED_DEADLINE has replaced CBS with the Greedy Reclamation of Unused Bandwidth (GRUB) algorithm.

更新 2:自 Linux 4.13 起,SCHED_DEADLINE 已用贪婪回收未使用带宽 (GRUB) 算法取代了 CBS 。

回答by Drioueche Mohammed

Here is the differences between SCHED_OTHER, SCHED_FIFO and SCHED_RR based on Linux Manual (http://man7.org/linux/man-pages/man7/sched.7.html)

以下是基于 Linux 手册 ( http://man7.org/linux/man-pages/man7/sched.7.html) 的SCHED_OTHER、SCHED_FIFO 和 SCHED_RR 之间的差异

SCHED_FIFO: First in-first out scheduling

SCHED_FIFO:先进先出调度

SCHED_FIFOcan be used only with static priorities higher than 0, which means that when a SCHED_FIFO threads becomes runnable, it will always immediately preempt any currently running SCHED_OTHER, SCHED_BATCH, or SCHED_IDLE thread. SCHED_FIFO is a simple scheduling algorithm without time slicing.

SCHED_FIFO只能用于高于 0 的静态优先级,这意味着当 SCHED_FIFO 线程变为可运行时,它将始终立即抢占任何当前正在运行的 SCHED_OTHER、SCHED_BATCH 或 SCHED_IDLE 线程。SCHED_FIFO 是一种简单的调度算法,没有时间分片。

SCHED_RR: Round-robin scheduling

SCHED_RR:循环调度

SCHED_RRis a simple enhancement of SCHED_FIFO. Everything described above for SCHED_FIFO also applies to SCHED_RR, except that each thread is allowed to run only for a maximum time quantum. If a SCHED_RR thread has been running for a time period equal to or longer than the time quantum, it will be put at the end of the list for its priority.

SCHED_RR是 SCHED_FIFO 的简单增强。上面针对 SCHED_FIFO 描述的所有内容也适用于 SCHED_RR,除了每个线程只允许运行最大时间量。如果 SCHED_RR 线程已运行的时间段等于或长于时间片,则它会因其优先级而被放在列表的末尾。

SCHED_OTHER: Default Linux time-sharing scheduling

SCHED_OTHER:Linux 默认分时调度

SCHED_OTHERcan be used at only static priority 0 (i.e., threads under real-time policies always have priority over SCHED_OTHER processes. SCHED_OTHER is the standard Linux time-sharing scheduler that is intended for all threads that do not require the special real-time mechanisms.

SCHED_OTHER只能用于静态优先级 0(即实时策略下的线程始终优先于 SCHED_OTHER 进程。SCHED_OTHER 是标准的 Linux 分时调度程序,适用于所有不需要特殊实时机制的线程.