简体   繁体   English

实际使用Linux实时调度优先级(SCHED_FIFO和SCHED_RR)?

[英]Practical use of Linux real time scheduling priorities (SCHED_FIFO and SCHED_RR)?

I am experimenting with SCHED_FIFO and I am seeing some unexpected behaviour. 我正在尝试SCHED_FIFO ,我看到了一些意想不到的行为。 The server I am using has 12 cores with hyper-threading disabled. 我使用的服务器有12个内核,禁用了超线程。 All configurable interrupts have been set to run on CPU 0. 所有可配置中断都设置为在CPU 0上运行。

My program starts creates a thread for lower priority tasks using the pthreads library without changing the scheduling policy with CPU affinity set to core 0. The parent thread then sets its CPU affinity to core 3 and its own scheduling policy to SCHED_FIFO using sched_setscheduler() with pid zero and priority 1 and then starts running a non-blocking loop. 我的程序启动使用pthreads库为低优先级任务创建一个线程,而不更改CPU关联性设置为核心0的调度策略。然后,父线程使用sched_setscheduler()将其CPU亲和性设置为核心3,并将其自己的调度策略设置为SCHED_FIFO pid为零,优先级为1,然后开始运行非阻塞循环。

The program itself runs well. 该计划本身运行良好。 However, if I attempt to log into the server for a second time while the program is running the terminal is unresponsive until I stop my program. 但是,如果我在程序运行时尝试第二次登录服务器,则在我停止程序之前终端没有响应。 It is like the scheduler is trying to run other processes on the same core as the real time process. 这就像调度程序试图在与实时进程相同的核心上运行其他进程。

  1. What am I missing? 我错过了什么?
  2. Will the scheduler still attempt to run other processes on a core running a real time process? 调度程序是否仍会尝试在运行实时进程的核心上运行其他进程? If so, is there a way to prevent this? 如果是这样,有没有办法防止这种情况?
  3. Will setting the scheduling policy with sched_setscheduler() in the parent change the behaviour of the child that was created before? 是否在父级中使用sched_setscheduler()设置调度策略sched_setscheduler()更改之前创建的子级的行为?

Thanks in advance. 提前致谢。

sched_setscheduler sets the scheduler of the process , not the thread. sched_setscheduler设置进程的调度程序 ,而不是线程。 See: 看到:

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

If you want to set the scheduler for a thread, you need to use the pthread_attr_setschedpolicy and pthread_attr_setschedparam functions on the attribute object for the new thread before you create it. 如果要为线程设置调度程序,则需要在创建新线程的属性对象上使用pthread_attr_setschedpolicypthread_attr_setschedparam函数。

I'm not sure how conformant Linux is on honoring these requirements, but you should at least start out by making sure your code is correct to the specification, then adjust it as needed... 我不确定Linux是否符合这些要求,但至少应该首先确保您的代码符合规范,然后根据需要进行调整......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM