Re: getloadavg and proc filesystem
Actually, I am looking at /proc/stat and that is the problem...
I looked at the implementation of getloadavg to see how 'real
programmers' used
the proc filesystem. I do not see how the implementation (in glibc)
is protected
from the kernel changing the data underneath it while it is being
read....
ie: getloadavg open /proc/loadavg for O_RDONLY
getloadavg reads the first 4 bytes
kernel completely updates the file
getloadavg reads the rest of file.....
And as /proc/stat is bigger, the problem is likely to occur even more
often?!
Or am i just being stupid?
As for /proc/stat - I am unable to find complete doco for it....
man proc does not state what the last 3 columns in the 'cpu' lines
are....
Are these iowait and intr (soft) intr (hard)?
Thanks for any help,
Andrew
On Oct 4, 2005, at 6:19 PM, Andy Davidson wrote:
If you want to monitor just cpu utilisation, the load average isn't
going to be a great measure; IO slowdown will 'break' the load
average, for example.
You are probably better off looking at /proc/stat.
https://sourceforge.net/projects/loadinfo is an awful hack which
might be a good starting point.
Reply to: