0

Possible Duplicate:
Is it possible to limit a Linux process so that it can only run on a particular core on a particular machine?

I would like to know how can I bind a process to a particular cpu core on a Linux server? I am running Centos 5.5. As you can see from screenshot added as comment, i have two cores...

Is there a simple way to do this?

taskset -p pid returns pids current affinity mask: 3. How do i know which core that is? My server only has dual core.

Thanks for advice.

peerra
  • 1
  • 1
  • 2

2 Answers2

0

You can accomplish this with the taskset command.

See: Is it possible to limit a Linux process so that it can only run on a particular core on a particular machine?

ewwhite
  • 194,921
  • 91
  • 434
  • 799
0

This has been answered over on the Super User site. Though like one commenter said, you may find yourself with worse performance as the Linux Scheduler is pretty good.

Red Tux
  • 2,074
  • 13
  • 14
  • 4
    i appear to have taskset, but taskset -c 2 -p 4021 does not work. I get sched_setaffinity: Invalid argument failed to set pid 0's affinity. – peerra Jan 02 '12 at 15:06
  • First double check the manpage for taskset on your system, make sure you're not using an older version that supports different arguments or that something else is not awry. Also CPU's count from 0, lastly is there a process id of 4021 actually running when you execute the taskset command? – Red Tux Jan 02 '12 at 15:45
  • The "failed to set pid 0's affinity" message appears to be a bug (https://github.com/karelzak/util-linux/issues/413). As to why you are getting that message, do you have sufficient permission? – Paul Brannan Jun 21 '17 at 18:50