'load average' return values from sysinfo()
Hello all,
I am trying to sharpen my C skills. So as an exercise I have started rewriting some of the basic gnu utils from scratch. I am stuck on one small point in 'uptime' though. I have it working pretty good so far, however, I am not sure what do do with the 'load average' figures. The man page for sysinfo (which provides the load average figures) says: Code:
unsigned long loads[3]; /* 1, 5, and 15 minute load averages */ 354 4353 4545 0 75 etc etc.... My question is what do these numbers represent? I cannot format them into the typical "load average: 0.00, 0.00, 0.00" format used by uptime unless I understand what the figures actually represent.... Are these even the same load average figures represented by uptime? Thanks for any insight. |
have you try to look at the source for sysinfo and see how they arrive at that values?
below is the getloadavg function that works on my linux, if it suits your rewrites of gnu util ,maybe you can temporary use it until you found a way to get a "0.00" values from sysinfo : Code:
|
Quote:
As for your code, thanks but I already have the values written into my program, converted to floats as you have done here. What I really need to know is what the figures represent... Here's a run of my uptime and gnu uptime: Code:
$ ./my_uptime 7200 5056 5824 0.10 0.08 0.09 So my question remains, what do 7200, 5056, and 5824 actually represent? Instructions per second? Miles per hour? Rods per hogshead? I'll try to find the function in the source... EDIT: well, after an hour or so I found it in /usr/src/linux/kernel/timer.c from function sys_sysinfo: Code:
val.loads[0] = avenrun[0] << (SI_LOAD_SHIFT - FSHIFT); Code:
static inline void calc_load(unsigned long ticks) |
i look again at getloadavg.c , uptime.c and kind of blur for me.
getloadavg is using Proc file to get their values! in BSD there's a DEFINE for : Code:
#define LINUX_SYSINFO_LOADS_SCALE 65536 Code:
doing a scaling of floating-point , am not too sure about it........ sorry can't help you with an exact answer:( anybody out there looking at this ......? |
Quote:
Anyway, that 65536 value you found seems to be the one I'm looking for. I tried dividing the load average by the machines bogomips, but the figures were still out of whack. The return values I'm getting divided by 65536 gives me the GNU output exactly (...rounded to 2 decimal places), so the mystery is solved... Thanks for your help alred! |
All times are GMT -5. The time now is 06:59 PM. |