Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

marked as duplicate by Iain, Ben Pilbrow, Holocryptic, Khaled, Ward Jan 2 '12 at 15:53

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
screensnapr.com/v/okyD2v.png –  peerra Jan 2 '12 at 14:56

2 Answers 2

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.

share|improve this answer
2  
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 '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 2 '12 at 15:45

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