how to get the cpu usage of a process ?

Dear all,
how to get the cpu usage of a process and write the demo app on QNX?
thanks,
tuyndie

I think this is also via devctl() function.
Not sure about the parameters for cpuusage, or if this is included in any of the procfs_structs

Dear all,
i search on interrupt and find CPU usage calculation concept:

For calculating the CPU usage of processes we need to get a value that indicates for how much time they have used the processor in a certain period of time, this value is equal to the sum of the time that the kernel and the user have spent on these processes

After we get this value, we keep it for the next run (the refresh time is usually 1.5 seconds) we then decrease the new value from the old value and divide it by the refresh time. I know it sounds complicated, the following code will explain it better:

private void CalcCpu()
{
    // refresh delay 1.5 seconds    
    int RefreshInterval = 1500; 
    // keeps the previous usage value.
    long OldRawUsageValue = GetCurrentUsageValue(); 
    // keeps the current usage value.
    long NewRawUsageValue;
    // holds the cpu usage in a friendly reading way. 
    string CpuUsage; 

    Thread.Sleep(RefreshInterval);

    while (KeepCalculation)
    {
        NewRawUsageValue = GetCurrentUsageValue();
        CpuUsage = ((int)((NewRawUsageValue - OldRawUsageValue) / 
                                  RefreshInterval)).ToString() + "%";
        Thread.Sleep(RefreshInterval);
        OldRawUsageValue = NewRawUsageValue;
    }
}

is it right when it runs on QNX of a process?
thanks,
tuyndie

You can get CPU usage of each process by sending DCMD_PROC_INFO to each entry in /proc/*/as.

If you can find the source to spin, there are code in there that just does that.