Can I hang a Linux box with the SCHED_FIFO process?

I want my computer to run in real time. :)

I played a little with this. I created a process which is essentially while (1) (never blocks or gives the processor) and used schedtool to start it using the SCHED_FIFO policy (also tried chrt ). However, this process allowed to start other processes.

Then someone told me about sched_rt_runtime_us and sched_rt_period_us . So I set the runtime to -1 to make the real-time process busy with the processor (and also tried to make both values ​​the same), but it didn't work either.

I am on a Linux 2.6.27-16 server, on a virtual machine with one processor. What am I doing wrong?

Thanks,

EDITOR: I do not want to use a plug. I just want one process to start forever, not letting other processes start.

+4
source share
3 answers

There is another defense that I did not know about.

If you have only one processor and you need a SCHED_FIFO process like this (one that never blocks and does not give the processor voluntarily) in order to monopolize it, in addition to having a high priority (in most cases this is not necessary, t it hurts), you should:

  • Set sched_rt_runtime_us to -1 or the value of sched_rt_period_us
  • If group scheduling is configured, set /cgroup/cpu.rt_runtime_us to -1 (in case you mount the cgroup file system to /cgroup )

Apparently, I set up group scheduling and did not bypass the last defense.

If you have N processors and want your N processes to monopolize the processor, you just do the same, but start all of them from your shell (the shell should not get stuck until you run the latter, since the processors will work on it ) If you want to be sure that each process will switch to a different processor, set its compatibility with the processor accordingly.

Thanks everyone for the answers.

+5
source

I'm not sure about schedtool, but if you successfully change the scheduler using sched_setscheduler to SCHED_FIFO, run a task that does not block, then one core will be fully allocated for the task. If this is the only kernel, no SCHED_OTHER tasks will be executed at all (for example, all but a few kernel threads).

I tried it myself.

Therefore, I assume that either your "non-blocking" task blocked, or your schedtool program could not change the scheduler (or changed it to the wrong task).

+3
source

You can also force SCHED_FIFO to be processed with the highest priority 1. Thus, the process will run forever and it will not be missed previously.

+1
source

All Articles