CPU utilisation - IS THIS EQUATION CORRECT
I wrote a test program to get the CPU utilisation. I hope to extend it to take cpu utilisation on multi core machines. Hear I used the equation
for taking cpu utilisation given at http://ubuntuforums.org/showthread.php?t=148781 of JmSchanck post. But when I match the output of my program against 'top' and 'system monitor' output it seems quite high. Sometimes cpu utilisation goes more than 100%. So the given equation in that url is correct??? can anyone give me the equation to take CPU utilisation??? Code:
#include <stdio.h> |
For each column (you seem to have three more than I was able to identify) compute the jiffy-count during the interval. You seem to be doing this. Then I think you want to sum the jiffies for each column. The idle time is the complement of the busy time, so:
Code:
# Pseudo-code --- rod. |
Code:
# Pseudo-code What is mean by 'idle' in the Pseudo-code sir? How is that calculate sir? totalJiffies= addition of /proc/stat file's cpu line's values?????? ISN'T IT |
Each of the columns in the 'cpu ' line represents the number of jiffies used by that state. One of the states (the fourth numeric column) represents the count of idle jiffies. Anything not in the idle state is 'busy'. Your code breaks up the columns into an array where each column is numbered. I chose to name the columns in the pseudo-code to reflect the meaning of each column. The sum of all columns will be the total number of jiffies over the interval. If the interval is repeated and is a constant time, the total jiffy count will be (nearly) constant for each interval. The percentage of time spent in the idle state can then be calculated as a fraction of the total time. The complement of this would be the 'busy' time.
--- rod. |
All times are GMT -5. The time now is 01:56 AM. |