Let's say I have a quad-core box and four identical processes, each with ten threads. Is it possible, in Linux, to say that Process A is only allowed to run on CPU 0, Process B is only allowed to run on CPU 1, etc?
to set process 12345 to use only processor/core 1
The bitmask can be a list (i.e. 1,3,4 to use cores 1 3 and 4 of a 4+ core system) or a bitmask in hex (0x0000000D the 1,3,4, 0x00000001 for just core 1)
Edit: almost forgot... If you want to set the affinity of a new command instead of change it for an existing process, use:
taskset (util-linux 2.13-pre7) usage: taskset [options] [mask | cpu-list] [pid | cmd [args...]] set or get the affinity of a process
-p, --pid operate on existing given pid -c, --cpu-list display and specify cpus in list format -h, --help display this help -v, --version output version information
The default behavior is to run a new command: taskset 03 sshd -b 1024 You can retrieve the mask of an existing task: taskset -p 700 Or set it: taskset -p 03 700 List format uses a comma-separated list instead of a mask: taskset -pc 0,3,7-11 700 Ranges in list format can take a stride argument: e.g. 0-31:2 is equivalent to mask 0x55555555
you can alway optimize you server as u r need