Setting Processor Affinity (Binding process or thread to CPU)

Processor affinity, or CPU pinning enables the binding and unbinding of a process or a thread to a central processing unit (CPU) or a range of CPUs, so that the process or thread will execute only on the designated CPU or CPUs rather than any CPU.


taskset -c <cpu> <command> --option     # start a command with the given affinity
taskset -c -p <cpu> <pid>               # set the affinity of a running process