Get / set CPU affinity (Linux)


/ Published in: Bash
Save to your folder(s)

Start jobs bound to certain CPU(s), or find the number of available CPUs.


Copy this code and paste it in your HTML
  1. # Bit mask of all CPUs: (affinity mask of init process)
  2. taskset -p 1
  3.  
  4. # CPUs allowed for this shell:
  5. taskset -p $$
  6.  
  7. # Start job with given CPU mask:
  8. taskset mask command
  9.  
  10. # Get / Set CPU mask of running command:
  11. taskset -p `pidof command`
  12.  
  13. taskset -p newmask `pidof command`

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.