1834440 Members
2508 Online
110067 Solutions
New Discussion

Re: Dumb question

 
SOLVED
Go to solution
Nicolas Dumeige
Esteemed Contributor

Dumb question

Hello

How is possible to have more processes in running state than the number of CPU ?

Thanks
All different, all Unix
6 REPLIES 6
Mark Grant
Honored Contributor
Solution

Re: Dumb question

Yes it is.

No in any instant of time but most measurements are taken over a period of time, even if it's just one second. In that second, several processes might run.

To give exact answers, I guess, it would be interesting to know just how you are determining that a process is running.

Not such a dumb question though :)
Never preceed any demonstration with anything more predictive than "watch this"
Steven E. Protter
Exalted Contributor

Re: Dumb question

Yes,

Your processor time slices many times a second. Running is a state that many processes can be in. The other states are for processes that for example may be awaiting input or child processes to finish.

The only dumb question btw is the one not asked.

It was a very good question in my opinion.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Geoff Wild
Honored Contributor

Re: Dumb question

Yes - this is normal for a "true" multi tasking OS.

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Jean-Luc Oudart
Honored Contributor

Re: Dumb question

To me there are only few state for a process :
- Active (running)
- Waiting for a resource (IO, ...)
- Sleeping (one may say that you're in a sleeping state when waiting for a resource. My understanding is sleeping is from your own will ;-) - the process put itself to sleep whereas waiting for an IO the process has no choice !)

from the man ps you have :

state The state of the process:

0 Nonexistent
S Sleeping
W Waiting
R Running
I Intermediate
Z Terminated
T Stopped
X Growing

Therefore on a 4 cpus system only 4 processes can really be active at any one time.
Now, perf tools may give results for a certain amount of time - that you can adjust.

Regards,
Jean-Luc
fiat lux
Nicolas Dumeige
Esteemed Contributor

Re: Dumb question

Mark,

I was just look at top.
I've tryed to get similar output from ps this way :

while :
do
ps -efo s | grep R | wc -l
sleep 3
done

The issue is the reliability of the measurement tool ?

All different, all Unix
Mark Grant
Honored Contributor

Re: Dumb question

Nicolas,

Not really the reliability as such but whilst your measuring tool, e.g. "ps" or "top" is getting cpu time then the processes you are monitoring can not, because in reality, two processes can't be on the CPU at any instant in time. Therefore an average is the best you can hope for.

Furthermore, the process table is actually changing whilst "ps" is working so it can't possibly be accurate. The "man" page for "ps" used to say something to this effect and added something like "but nothing about ps is reliable anyway". I think they took that out because "ps" is good enough for everyday use.

To find out exactly what is on the CPU at any one time, the kernel would have to find some way of dumping the process table without actually running. This would be rather cool
Never preceed any demonstration with anything more predictive than "watch this"