Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to set CPU affinity using taskset

📅 2016-Feb-17 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ cpu affinity, taskset ⬩ 📚 Archive

taskset is a tool that can be used to get and set the CPU affinity of a running process. This can be useful to find out which of the cores or CPUs of your system has been assigned to a given process by the Linux scheduler. You can use this tool to change, increase or decrease the cores assigned to a process.

$ taskset -p 25694
pid 25694's current affinity list: 0,1
$ taskset -c -p 2 25694
pid 25694's current affinity list: 0,1
pid 25694's new affinity list: 2
$ taskset -c -p 4-7 25694
pid 25694's current affinity list: 0,1
pid 25694's new affinity list: 4,5,6,7

Tried with: Util-Linux 2.26.2 and Ubuntu 15.10


© 2022 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘 @codeyarns@hachyderm.io📧