Linux reserve a processor for a group of processes

2019-04-09 12:11发布

问题:

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.