Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Possible Duplicate:
How can I set the processor affinity of a process on Linux?

Computer CPUs have many cores insde them nowadays.

I have always wondered if there is a way to, when I start a process on the Linux command line, specify which particular core or cores that process might use?

For example, can I start a massive grep task and say "use ALL of CPU2 for yourself".

Or could I start a find task and say "never leave CPU3".

Or maybe I could start a video decoding task and say "use whatever is available on CPU1 and CPU2"

OR, is there no way to do this because it is not needed and the OS is doing this kind of stuff intelligently by itself (based on nice levels and general resource usage of the process etc)

IfyouknowwhatImean

share|improve this question

marked as duplicate by Mat, jasonwryan, Gilles, warl0ck, Renan Sep 12 '12 at 19:03

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.

add comment

2 Answers 2

What you are wondering about is CPU Affinity. I found that there was a good explanation of CPU affinity on NixCraft. But note that the Linux kernel is indeed, as you say, already making intelligent choices.

share|improve this answer
2  
And thankfully I don't know of many linux apps that charge you using a per-core licence (MSSQL I'm looking at you) –  Rqomey Sep 10 '12 at 14:18
add comment

See the taskset utility. Should be exactly what you're looking for.

share|improve this answer
add comment

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