Linux SCHED_OTHER, SCHED_FIFO and SCHED_RR - differences
Asked Answered
C

2

53

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

Thanks

Commentate answered 22/2, 2012 at 9:44 Comment(2)
Quite duplicated with that one linux :-) : https://mcmap.net/q/77179/-real-time-scheduling-in-linuxEmboss
Not exactly, SCHED_OTHER wasn't mentionedCommentate
B
75

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).

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_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.

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 First queues. 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.

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

Bolduc answered 24/5, 2013 at 8:26 Comment(2)
Note also that the Linux scheduler can throttle down misbehaving processes under SCHED_DEADLINE, so other processes get CPU time. See e.g. youtube.com/watch?v=AmyfSjRMcIY and retis.sssup.it/~jlelli/talks/rts-like14/SCHED_DEADLINE.pdf . I.e. if a SCHED_DEADLINE process says it will need 2 timeslices out of 5, but consumes more than that, it will be throttled down if necessary. To acheive something like hard realtime on Linux, SCHED_DEADLINE is probably the best choice.Norther
Thanks for those links. Time has passed and one is now bad. I found this and thisVanish
S
7

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)

SCHED_FIFO: First in-first out scheduling

SCHED_FIFO can 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_RR: Round-robin scheduling

SCHED_RR is 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_OTHER: Default Linux time-sharing scheduling

SCHED_OTHER can 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.

Sheaves answered 24/12, 2019 at 11:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.