On all of BSD/Linux/MacOS and Solaris, I made an observation – no matter how busy the system is, top
always reports very few (usually 1-2) running processes.
According to my limited understanding, a process is in "running" state if it is using CPU time, or waiting for CPU time to become available.
So, here is a scenario: I use SSH to tunnel VNC, then run top
on remote machine, in a Terminal emulator:
top
itself is listed as a "running" process (understandable)sshd
is listed, but not "running"Xvnc
is listed, but not "running"
But sshd
is tunneling VNC traffic, Xvnc
is what keeps me updated with screen content, how can they not be using CPU time?
If they are using CPU time, then how come they are not "running"?
Best Answer
I believe this is a question of timing.
top
checks CPU state every N seconds. At the moment the check is run,top
will have to be active since it is actively checking the state of the system. A nice way of seing this in action is to decrease the update time oftop
and watch your processes move! As suggested inman top
:If you try this, you should see more processes going into
R
mode. You can also try runningtop
in batch mode a few times and collecting the processes that are marked as running:On my system under its current load (which includes an open ssh tunnel) I get the following processes: