Linux Foundation Wiki

project collaboration site

User Tools

Site Tools


realtime:documentation:technical_basics:sched_policy_prio:start

Scheduling - Policy and Priority

Depending on the chosen task policy and associated rules the scheduler decides which task is swapped out and which task is processed next. The Linux kernel implements several scheduling policies. They are divided into non real-time and real-time policies. The scheduling policies are already implemented in mainline Linux.

Non real-time policies:

  • SCHED_OTHER: Every task gets a so called 'nice value'. It is a value between -20 for the highest nice value and 19 for the lowest nice value. The average value of execution time of the task depends on the associated nice value.
  • SCHED_BATCH: This policy is derived from SCHED_OTHER and is optimized for throughput.
  • SCHED_IDLE: It is also derived from SCHED_OTHER, but it has nice values weaker than 19.

Real-time policies:

  • SCHED_FIFO: Tasks have a priority between 1 (low) and 99 (high). A task running under this policy is scheduled until it finishes or a higher prioritized task preempts it.
  • SCHED_RR: This policy is derived from SCHED_FIFO. The difference to SCHED_FIFO is that a task runs for the duration of a defined time slice (if it is not preempted by a higher prioritized task). It can be interrupted by a task with the same priority once the time slice is used up. The time slice definition is exported in procfs (/proc/sys/kernel/sched_rr_timeslice_ms).
  • SCHED_DEADLINE: This policy implements the Global Earliest Deadline First (GEDF) algorithm. Tasks scheduled under this policy can preempt any task scheduled with SCHED_FIFO or SCHED_RR.
realtime/documentation/technical_basics/sched_policy_prio/start.txt · Last modified: 2017/12/05 08:22 by anna-maria