taskset command is written by Robert M. Love. It makes use of the Linux kernel system calls (sched_setaffinity and sched_getaffinity) to set the CPU affinity.
Taskset is part of util-linux and the source code is hosted on kernel.org:
https://git.kernel.org/pub/scm/utils/util-linux/util-linux.git
The util-linux can be easily installed with the prebuilt package “util-linux”. On a Debian system therefore execute:
$ sudo apt-get update $ sudo apt-get install util-linux
To change the CPU affinity of a task, the user needs the capability CAP_SYS_NICE.
Only a collection of possible use cases is given here. For a detailed documentation of all available parameters, please refere to the man page:
$ man taskset
Start an application foo on CPU 3:
$ taskset -c 3 foo
The CPU affinity can be read out of an allready running task with: PID 4711
$ taskset -p 4711
The CPU affinity of the task with pid 4711 can be changed afterwards:
$ taskset -p 0x0003 4711