There was some posting on this matter, Search : /proc/1/as
To my knowledge sending DCMD_PROC_TIDSTATUS brings back some statistical info, which might be used to measure CPU utilization.
Frankly said I have never tried this.
I tried hogs and the result printed out is what I was looking for. The only think is that I rather like to have more control over when to read the values and select for example only the idle thread to monitor. In one posting somebody mentioned to look into the source code of hogs. Is this possible since the source code is not available?
Concerning the other hint about the DCMD_PROC_TIDSTATUS:
Here I could only find:
_Uint64t start_time; /* thread start time in nsec /
_Uint64t sutime; / thread system + user running time in nsec */
out of the debug_thread_t; struct defined in debug.h which may help to calculate the cpu load.
Strange think is that the start_time remains 0.
Do you see any other way to retrieve the cpu load?
Yes, there ARE clock_getcpuclockid() and pthread_getcpuclockid() but neither of those allows you to specify BOTH pid and tid, which is what you need here.
You should be able to use clock_gettime() though - that simply makes use of the clock id returned.