0

A question about scheduling in Linux:

  • I have several processes scheduled with CFS and one process "A" that is running with Real-Time (RT) (SCHED_FIFO) scheduling - all process are bind to one specific CPU core.
  • The process "A" is running on RT (SCHED_FIFO) because it should never be preempted for the other CFS processes.
  • Instead, process "A" will release the CPU voluntarily when it decides, and let the other processes (scheduled with CFS) to utilize the CPU.

Now the question:

  • How can process "A" release the CPU and let the other CFS processes that are ready to run, to take the CPU?
  • If "A" changes its policy to CFS (SCHED_OTHER), then the Linux scheduler will potentially let it also run.
  • Also if "A" changes its policy to IDLE, still the scheduler may let it run.

I want process "A" to get the CPU back when:

  • There are no other CFS processes that are ready to run, OR a predefined time (e.g. 10ms) is passed - whichever happens first.
  • The second condition can be achieved by another process (running on ther CPU core) that will change "A" policy back to RT.

Any ideas on how this can be achieved?

More specifically, how to guarantee that only the other ready CFS processes will run, and not "A", until one of the mentioned conditions is met?

Thanks!

  • @KamilCuk, with 'sched_setscheduler' or 'pthread_setschedparam'. sorry I accidently deleted your comment asking how I set the process "A" to Real-Time. – user1868481 Jun 05 '19 at 10:17
  • Can you post a full invokation of these function? I don't understand, really, the default CFS doesn't "guarantee" cpu time on specific processor (well, according to my limited knowledge). Did you patch the kernel? What is your `uname -a`? Are you using some default kernel config? Realtime, it's just a priority, niceness below -20. It doesn't "guarantee" the cpu, how did you achieve that? So did you use `SCHED_FIFO`? `SCHED_RR`? `SCHED_DEADLINE`? What priority? How did you configure that? So maybe, from the other side, what does `chrt -v -p $pid_of_your_process` shows? – KamilCuk Jun 06 '19 at 07:51
  • @KamilCuk, The process "A" is set to SCHED_FIFO (while all others are SCHED_OTHER which is the CFS). Therefore, "A" will get the CPU and never be preempted for the CFS processes (except for the guarantee percentage, as defined by sched_rt_runtime_us). All processes including A are bind to a specific CPU core. – user1868481 Jun 06 '19 at 08:41

0 Answers0