0

I'm trying to implement a real-time algorithm in Linux.

I've studied the linux Real-Time policies : sched_rr, sched_fifo.

Than i go deeper and i found the Completely Fair Scheduler. I deduced that if i use the CFS i lose the predicibily since CFS cares only about fairness.

If i want to implement rigorously a real-time scheduling algorithm i should not use CFS. Am i correct ? If yes, what Linux Scheduler shoud i use ?

1

CFS shares bandwidth fairly between different concurrent workloads in a way that gives interactive workloads appealing low latencies. Real-time means meeting a deadline, which sounds like, but is not same as, low latency. As CFS does not offer deadline, it is not suited for real-time. I suggest you look into SCHED_DEADLINE scheduler. It is a fairly good general purpose real-time scheduler for periodic or sporadic tasks with deadlines.

SCHED_DEADLINE tasks have the highest priority of all and thus pre-empt all other tasks. SCHED_RR and SCHED_FIFO are scheduled according to priority 1 to 99, where larger number pre-empts lower priorities. SCHED_OTHER is priority 0, which is lower than the previous and therefore this CFS scheduler gets only CPU as left over from real-time tasks. Real-time schedulers can allocate at most 95% of CPU bandwidth leaving SCHED_OTHER tasks 5% of bandwidth (unless changed via sysctl). There are also SCHED_BATCH and SCHED_IDLE, which tell scheduler to give different disadvantages compared SCHED_OTHER. The Linux man page sched(7) gives more details.

  • By default, does Linux schedule sched_rr, sched_fifo and sched_other tasks using CFS ? And it's possible to use only the sched_deadline, inhibiting the CFS ? – Qwerto Jul 12 '18 at 12:46
  • No. CFS does not schedule real-time. I've added to the answer how the policies relate and a link to sched(7) man page that has a decent explanation. – Marko Kohtala Jul 14 '18 at 16:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.