Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Sometimes when a process is suspended (in T state) the output of ps shows the process using an unusual amount of CPU%.

USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
cossey    8697 26.9  0.0   8808   672 pts/3    T    09:25   0:22 gzip

Is this a bug in ps?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

In some versions of ps, the %CPU column shows the average CPU usage over the entire life of the process. Others implement a decaying average (http://www.google.com/search?q=ps+cpu+decaying+average) but even with that you'd have to wait a while after suspending for the average to drop to 0.

POSIX says:

pcpu

The ratio of CPU time used recently to CPU time available in the same period, expressed as a percentage. The meaning of "recently" in this context is unspecified. The CPU time available is determined in an unspecified manner.

And the rationale:

The pcpu field indicates that the CPU time available is determined in an unspecified manner. This is because it is difficult to express an algorithm that is useful across all possible machine architectures. Historical counterparts to this value have attempted to show percentage of use in the recent past, such as the preceding minute. Frequently, these values for all processes did not add up to 100%. Implementations are encouraged to provide data in this field to users that will help them identify processes currently affecting the performance of the system.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.