Practical use of Linux real-time scheduling priorities (SCHED_FIFO and SCHED_RR)?

I am experimenting with SCHED_FIFO and I see some unexpected behavior. The server I use has 12 cores with hyperthread disabled. All configurable interrupts have been configured to operate on CPU 0.

My program launches a thread for tasks with a lower priority, using the pthreads library, without changing the scheduling policy bound to the processor installed on kernel 0. The parent thread then sets the affinity for processor 3 and its own scheduling policy to SCHED_FIFO using sched_setscheduler() with pid zero and priority 1, and then starts a non-blocking cycle.

The program itself works well. However, if I try to enter the server a second time while the program is running, the terminal does not respond until I stop my program. It looks like the scheduler is trying to start other processes in the same kernel as in real time.

  • What am I missing?
  • Will the scheduler still try to run other processes in the real-time kernel? If so, is there a way to prevent this?
  • Will there be a scheduling policy setting with sched_setscheduler() in the parent behavior change of the child that was created before?

Thanks in advance.

+6
source share
1 answer

sched_setscheduler defines the process scheduler, not the thread. Cm:

http://pubs.opengroup.org/onlinepubs/9699919799/functions/sched_setscheduler.html

If you want to set a scheduler for a thread, you need to use the pthread_attr_setschedpolicy and pthread_attr_setschedparam functions for the attribute object for the new thread before creating it.

I'm not sure how compatible Linux complies with these requirements, but you should at least start by making sure your code is correct to the specification, and then adjust it if necessary ...

+5
source

Source: https://habr.com/ru/post/915556/


All Articles