Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I wish to pin a process to a CPU1 in my dual CPU machine - how can I do it in Linux - any pointers ?

share|improve this question

migrated from stackoverflow.com Mar 25 '11 at 8:16

This question came from our site for professional and enthusiast programmers.

1  
The usual response to questions like this is why? The OS generally knows better than you! (Thought I'd ask this question cos someone will!) –  Jon Egerton Mar 24 '11 at 12:41
    
You can use processor affinity (install schedutils) and use taskset -c 1 -p <PID>. But since you have only 2 processors until and unless you have very strong reasons avoid it. –  Zimbabao Mar 24 '11 at 12:50

2 Answers 2

You should think long and hard about why you think you're smarter than the scheduler. After that, if you still want to set the cpu affinity of a process on linux you can use the taskset command or, if you're writing the program yourself, the sched_setaffinity system call.

share|improve this answer
    
For example, it is essentially always wrong to migrate a compute-bound process with intensive cache re-use. –  mabraham May 28 at 16:11

Fwiw: we did this, pinning every process in an averagely complex application that we well mastered. We found out that the linux kernel scheduler is better than us at allowing processors and processing time, as others stated above ...

share|improve this answer

Your Answer

 
discard

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.