3

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

2
  • 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
    Commented Mar 24, 2011 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
    Commented Mar 24, 2011 at 12:50

2 Answers 2

8

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.

1
  • 1
    For example, it is essentially always wrong to migrate a compute-bound process with intensive cache re-use.
    – mabraham
    Commented May 28, 2014 at 16:11
1

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 ...

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .