How can I run command and select core to be used
I have a command to run (in this case is a php5 script) and I would like to know if there is something to run this command and select the core to be runed.
What I want to do is to run 1 command per each core to use the multiple cores of my server.
Any idea? Or I have to rewrite the script in other languages with multicore support and develop the core control directly in the script?
The command to run or assign a specific command to a particular core is taskset
.
Embed it in your startup script or use from the command line like:
taskset -c 0,5 command_name
-c
is a list of one or more CPUs to run the command on; in this case, core 0 and 5.
You can also modify the core assignment of a running process by specifying a PID with taskset
.
But you may also want to see: Assigning Processes to CPU Cores
Your kernels scheduler will do this just fine all by itself and doesn't need a user to do his work.