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.

link|improve this question
feedback

closed as exact duplicate by Iain, Ben Pilbrow, Holocryptic, Khaled, Ward Jan 2 at 15:53

This question covers exactly the same ground as earlier questions on this topic; its answers may be merged with another identical question. See the FAQ for guidance on how to improve it.

2 Answers

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?

link|improve this answer
feedback

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.

link|improve this answer
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 2 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 2 at 15:45
feedback

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