LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   cpu core utilization (https://www.linuxquestions.org/questions/programming-9/cpu-core-utilization-786828/)

chamila1986 02-03-2010 10:06 PM

cpu core utilization
 
Can anyone explain the way that I can get the current cpu core utilization for each cpu core in multi core machine pragmatically(In C )...

neonsignal 02-03-2010 11:09 PM

A method is:

1. open /proc/stat
2. read in the idle (and perhaps iowait) times for each processor (see man /proc for a description of the format)
3. wait one second
4. read in the idle times again
5. find the differences and divide by the tick frequency

This will give you the idle fraction for each cpu over the last second.


All times are GMT -5. The time now is 03:26 PM.