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 – is derived from SCHED_OTHER and is optimized for throughput.
SCHED_IDLE – 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 – 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 – implements the Global Earliest Deadline First (GEDF) algorithm. Tasks scheduled under this policy can preempt any task scheduled with SCHED_FIFO or SCHED_RR.