CPU Affinity

thoonie

hmmm....
First off, how do you list all processes that are running using ssh? And how do you set the affinity of a process to one core of a CPU in Linux (anydistro)?
 
First off, how do you list all processes that are running using ssh?
Let me explain that SSH, or Secure SHell, is simply a way to securely connect to and get a remote shell on a Linux/UNIX system. Commands "in SSH" are actually relative to what shell you're getting once you SSH; SSH isn't a shell in itself. But, that all said, you can list all process like so:
Code:
ps -A
...or alternately, if you only wanted to list the processes for one particular user, you could do
Code:
ps -u $USER
... Where $USER should be the actual username.

And how do you set the affinity of a process to one core of a CPU in Linux (anydistro)?
Linux kernel >=2.5 has built-in natural process affinity, which means that it will try and keep a process tied to a particular CPU as much as possible by default. This is very good behavior. However, you can manually bind a process to a particular CPU quite easily (you must own the process or be root):
Code:
bind [I]pid cpu_mask[/I]
...where pid = the process ID and cpu_mask = the decimal ID of the CPU (e.g. 1, 2, 3 etc). So for an example, if I wanted to bind my UT2004 server (with PID 242424) to the 2nd CPU on my server, I'd do this:
Code:
bind 242424 2
 
Back
Top