Linux为一组进程保留处理器(动态地) [英] Linux reserve a processor for a group of processes (dynamically)
问题描述
有没有一种方法可以将处理器排除在正常调度之外?
Is there a way to exclude a processor from normal scheduling?
也就是说,使用sched_setaffinity
我可以指示线程应该在哪个处理器上运行,但是我正在寻找某种相反的说法.也就是说,我想从正常调度中排除给定的处理器,以便只有在那里明确调度的进程才能在其中运行.
That is, using sched_setaffinity
I can indicate which processor a thread should run on, but I'm looking for kind of the inverse. That is, I want exclude a given processor from the normal scheduling, such that only processes which have been explicitly scheduled there can run there.
我还知道,在引导过程中,我可以限制init进程使用的处理器,因此可以限制所有继承的进程.但是,我希望有比这更动态的解决方案-在启动后我可以更改某些内容.
I also know that during boot I can limit the processors used by the init process, thus all inherited process. I was however hoping there would be a more dynamic solution than this -- something I can change post-boot.
请注意,我希望调度线程,而不仅仅是高级进程(这在某些情况下可能会有所作为).
推荐答案
cgroups,或者具体地说,cgroups基础结构的cpuset部分是在Linux中实现此目的的方法.请参见 http://www.kernel.org/doc中的1.4节专有cpusets" /Documentation/cgroups/cpusets.txt .
cgroups, or specifically, the cpuset part of the cgroups infrastructure is the way to do it in Linux. See section 1.4 "exclusive cpusets" in http://www.kernel.org/doc/Documentation/cgroups/cpusets.txt .
然后,如果如您在评论中所述,如果系统未启用cpuset,则表示您不走运.
Then again, if, as you say in a comment, your system does not have cpusets enabled, you're out of luck.
此外,您所要求的也许有点不合常规.也许,如果您要解释自己实际要实现的目标,就能为您提供替代解决方案.
Also, what you're asking for is perhaps slightly un-orthodox; perhaps if you were to explain what you're actually trying to achieve people would be able to point you to alternative solutions.
这篇关于Linux为一组进程保留处理器(动态地)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!