Setting CPU affinity using taskset
I am using the taskset tool to set CPU affinity for one of my programs. How do I set the affinity on a 开发者_Python百科single CPU only - since I was not sure about this, so I was doing this:
taskset -c 2-2 tests/prog 1 2 3
...expecting, that I am scheduling the program to run on CPU #2 only, following the similar way for other CPUs. Even if I'm right, this is a bad way to perform what I want IMO, can I get some help?
Thank you,
SayanEasiest way would be using the CPU masks like
taskset -p mask pid
#taskset -p 0x00000001 11587
pid 11587's current affinity mask: ff
pid 11587's new affinity mask: 1
taskset -c 2 ...
should work to pin the program to CPU #2 (which is the third CPU -- CPUs are numbered from 0).
Even if I'm right, this is a bad way to perform what I want IMO, can I get some help?
Depends on what you want. What are you trying to accomplish?
精彩评论