Search code examples
clinuxaffinity

Linux CPU affinity for all system processes


Is there a way to set all system processes other than my own process' threads to their own CPU without manually setting each pid.

I am using C on Fedora and would like to set this on program start not before.


Solution

  • cgroups (control groups) are an effective way of partitioning system resources (even more than just CPUs). Also, another effective way of getting exclusive CPU access for a process is to leverage the scheduler -- give it higher priority than anything else.

    If those aren't what you want, and you've decided that you really, really want to control CPU affinity using single-bit masks, you can walk the process tree starting with init (try using system with this example of how to use ps at the shell).