Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have quad core CPU with hyper threading enabled. So I have 8 logical cores. I want to limit my application to use only 4 cores and I want this 4 cores to be different physical cores. Which taskset options (core numbers) should I use? :

  • taskset -c 0,1,2,3 command or
  • taskset -c 0,2,4,6 command

Thank you.

share|improve this question

You can see which cores are on which processors by taking at look at /proc/cpu info. For example, you will see on a machine with a dual core cpu

processor   : 0
core id     : 0
cpu cores   : 2

for the first core on the processor and

processor   : 1
core id : 1
cpu cores   : 2

on the second.

So, generally speaking, I think you would want

taskset -c 0,2,4,6


taskset -c 1,3,5,7
share|improve this answer

You may want to take a look at CPU Set (cset) to create a CPU shield group for your application. This way you can ensure that real cores are being used for the important work. I typically disable hyperthreading (on Nehalem systems) for my realtime and low-latency applications.

Here's a tutorial for creating groups of CPUs for specific applications/processes using cset, which is a little more organized than taskset.

As far as determining the core count and location assignments, take a look at:

A quick run of the utility linked on a quad-core Nehalem with hyperthreading enabled shows:

[root@XXX ~/hwloc-1.0.3]# ./utils/lstopo 
Machine (7980MB) + Socket #0 + L3 #0 (8192KB)
  L2 #0 (256KB) + L1 #0 (32KB) + Core #0
    PU #0 (phys=0)
    PU #1 (phys=4)
  L2 #1 (256KB) + L1 #1 (32KB) + Core #1
    PU #2 (phys=1)
    PU #3 (phys=5)
  L2 #2 (256KB) + L1 #2 (32KB) + Core #2
    PU #4 (phys=2)
    PU #5 (phys=6)
  L2 #3 (256KB) + L1 #3 (32KB) + Core #3
    PU #6 (phys=3)
    PU #7 (phys=7)
share|improve this answer

You can use like:

taskset -c -p 0-3 pid

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.