CPU utilization

Hi!

Where can I get the information about the CPU utilization?
I read somewhere it must be written in /proc/1/as, but
this file has a size of 0 Byte?
Is there anywhere a program which returns the CPU utilization (in
percent)? Or must I program it by using of time information from all
threads?

Thanx!

You can use ClockId and ClockTime to get the amount of time that idle is
running.

From the man page for ClockId…

file:///C:/QNX630/target/qnx6/usr/help/product/neutrino/lib_ref/c/clockid.html

id = ClockId(1, 1);
for( ;; ) {
ClockTime(id, NULL, &start);
sleep(1);
ClockTime(id, NULL, &stop);
printf(“load = %f%%\n”, (1000000000.0 - (stop-start)) / 10000000.0);
}

although in actual fact I would use

ClockTime(CLOCK_REALTIME, NULL, &start_system);

ClockTime(CLOCK_REALTIME, NULL, &stop_system);
elapsed = stop_system - start_system;

rather than assuming sleep(1) will sleep for exactly one second.

Note that system accounting is based on timer tick sampling, so you may
get some weird results if your application is running frequently for
short periods of time. In this case the system profiler is more suited
for performance characterisation.

MOSTMAN wrote:

Hi!

Where can I get the information about the CPU utilization?
I read somewhere it must be written in /proc/1/as, but
this file has a size of 0 Byte?
Is there anywhere a program which returns the CPU utilization (in
percent)? Or must I program it by using of time information from all
threads?

Thanx!


cburgess@qnx.com

Try running the ‘hogs’ utility.

“MOSTMAN” <christian.richter@soft-gate-dot-de.no-spam.invalid> schrieb im
Newsbeitrag news:d83qll$ma8$1@inn.qnx.com

Hi!

Where can I get the information about the CPU utilization?
I read somewhere it must be written in /proc/1/as, but
this file has a size of 0 Byte?
Is there anywhere a program which returns the CPU utilization (in
percent)? Or must I program it by using of time information from all
threads?

Thanx!

Colin Burgess schrieb:

You can use ClockId and ClockTime to get the amount of time that idle is
running.

From the man page for ClockId…

file:///C:/QNX630/target/qnx6/usr/help/product/neutrino/lib_ref/c/clockid.html
*

What a horrible link from a QNX guy.

id = ClockId(1, 1);
for( ;; ) {
ClockTime(id, NULL, &start);
sleep(1);
ClockTime(id, NULL, &stop);
printf(“load = %f%%\n”, (1000000000.0 - (stop-start)) / 10000000.0);
}

although in actual fact I would use

ClockTime(CLOCK_REALTIME, NULL, &start_system);

ClockTime(CLOCK_REALTIME, NULL, &stop_system);
elapsed = stop_system - start_system;

rather than assuming sleep(1) will sleep for exactly one second.

Note that system accounting is based on timer tick sampling, so you may
get some weird results if your application is running frequently for
short periods of time. In this case the system profiler is more suited
for performance characterisation.

MOSTMAN wrote:

Hi!

Where can I get the information about the CPU utilization?
I read somewhere it must be written in /proc/1/as, but
this file has a size of 0 Byte?
Is there anywhere a program which returns the CPU utilization (in
percent)? Or must I program it by using of time information from all
threads?

Thanx!

Michael Tasche wrote:

Colin Burgess schrieb:

You can use ClockId and ClockTime to get the amount of time that idle
is running.

From the man page for ClockId…

file:///C:/QNX630/target/qnx6/usr/help/product/neutrino/lib_ref/c/clockid.html


*
What a horrible link from a QNX guy.

Yes, I know… :v)

id = ClockId(1, 1);
for( ;; ) {
ClockTime(id, NULL, &start);
sleep(1);
ClockTime(id, NULL, &stop);
printf(“load = %f%%\n”, (1000000000.0 - (stop-start)) / 10000000.0);
}

although in actual fact I would use

ClockTime(CLOCK_REALTIME, NULL, &start_system);

ClockTime(CLOCK_REALTIME, NULL, &stop_system);
elapsed = stop_system - start_system;

rather than assuming sleep(1) will sleep for exactly one second.

Note that system accounting is based on timer tick sampling, so you
may get some weird results if your application is running frequently
for short periods of time. In this case the system profiler is more
suited for performance characterisation.

MOSTMAN wrote:

Hi!

Where can I get the information about the CPU utilization?
I read somewhere it must be written in /proc/1/as, but
this file has a size of 0 Byte?
Is there anywhere a program which returns the CPU utilization (in
percent)? Or must I program it by using of time information from all
threads?

Thanx!


cburgess@qnx.com