Linux reserve a processor for a group of processes (dynamically)

旧城冷巷雨未停 提交于 2019-12-12 08:55:14

问题


Is there a way to exclude a processor from normal scheduling?

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.

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.


Note that I'm looking to schedule threads, not just high-level processes (this might make a difference in some cases).


回答1:


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 .

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.



来源:https://stackoverflow.com/questions/6816069/linux-reserve-a-processor-for-a-group-of-processes-dynamically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!