ps bug

I noticed that with QNX 6.3.2 the ps command:

“ps -e -o pcpu,args”

Only ever outputs 0 for the cpu percentage (I have processes using 1% or higher).

Is there any other command (that will run to completion) and give me the cpu percentages of all processes running?

No answer to your question, but I did confirm the bug still exists in 6.4.1. Looking at the code itself, it’s a simple integer division problem when finding the percent. They do ((x/y)*100). Since x/y is always between 0 and 1 (except for 100% usage) and the variables are integers the x/y is always rounded down to 0 before the multiplication. It’s a simple fix so if you register at foundry27 and get access to the code you can fix it yourself. Anyway, I’ll post a bug to QNX so it will hopefully be fixed in a future release.

In the meantime there are a few options I know of, none of which satisfy all your stated requirements, that may be useful.
top -i 1

  • top displays the 10 biggest CPU users, by using “-i 1” top will run to completion after 1 iteration

pidin times

  • will display all processes and run to completion showing CPU usage, but displays usage as time rather than percentage

From what I’ve been told, all these utilities do a fairly poor job of measuring actual CPU usage and you should really try to use something like the System Profiler to get more accurate results.

Hope that helps
Steve

Thanks allot steve.

I do not seem to have top on my system though 0_o QNX version 6.3.2.

David,

Try ‘hogs -n -%1 -s#’ where # is the number of seconds you want to sample the CPU usage at. The %1 tells Hogs not to bother displaying any process that uses less than 1% of the CPU in the sample period.

Tim

There is a 3rd-party utility called spin. It works fine…