Help - Search - Members - Calendar
Full Version: HOW TO: Set a particular process to run on a specific cpu ( SMP )
linux-noob.com/forums > Linux Noob > Tips and Tricks
bluemoon
OK, Well znx needs to be thanked once again for this.

Where this can be used for example:

If you are running 4 gaming servers assuming you are using Dual Xeon processors with HT ( classed as 4 cpu's in linux)

Server 1 uses 60% CPU Usage
Server 2 Uses 60% CPU Usage
Server 3 Uses 20% CPU Usage
Server 4 Uses 20% CPU Usage

Rather than letting the distro automtically assign CPU's it is sometimes better for you to do it manually. In this instance it would make server to have

Server 1 using CPU0
Server 2 using CPU1
Server 3 + 4 using CPU2

Leaving you with a spare CPU.

Example of how to install this in Debian / Redhat / Other:

CODE
# apt-get install schedutils


Redhat

CODE
# up2date schedutils


Other

CODE
# rpm -ivh schedutils*



If you have a particular process running and it will retain the same PID throughout then you can do the following command:

CODE
# taskset -c 1 -p 13545


'-c 1- = Which cpu you wish the process to run on. In my example this can be set to Either ( CPU0, CPU1, CPU 2, CPU3 )

'-p 12345- Is the process, if the process does not retain the same PID then you need to do the following:

CODE
# taskset -c 3 ./server1.sh


If the 'respawning' script needs to be run in screen, you would do:

CODE
screen -m -d -s -- taskset -c 3 ./server1.sh


The parent and child, no matter how many times new children (therefore new PIDs) it will still run on CPU3 ( -c3 )

More information on this can be found @ http://www.cyberciti.biz/tips/setting-proc...or-process.html

And more information about re-spawning scripts can be found @ http://www.linux-noob.com/forums/index.php?showtopic=1746

I hope this helps.

Sorry if some of the lingo is incorrect. I tried my best, im a linux noob smile.gif

Thanks to znx again.
znx
This is awesome bluemoon. When we first discussed this I didn't think there was a utility capable of doing it. But you kept plugging away and researching!

It allows you more than just the ability to separate across CPUs. It will improve the frame rates on game servers!

Woot biggrin.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.