sysinfo question: what is the sysinfo.loads[0] mean ?

sysinfo question: what is the sysinfo.loads[0] mean ?

Post by Frank Sweetse » Tue, 16 Jun 1998 04:00:00

> Hi,
>     I'm working on a system information software with QT . I use the
> following code :
>   struct sysinfo info;
>  sysinfo(&info) ;
>  printf("%d",info.loads[0]);

>  I think it should be the same value of  /proc/loadavg , but it gives me
> a large number .
> Anyone can tell me what is the sysinfo.loads[0] mean  . Thanks a lot.

heh... just spent a few days myself on this problem.  the kernel can't use
any any floating point math, but the load average is not an integer, so
they use fixed point math on an unsigned long.  took a bit of digging
through kernel source to figure out how to extract the number.. here's a
code snippet.

        int whole, fract, tmp, i;
        float loads[3];

        for(i = 0 ; i >= 2 ; i++ ){
                tmp = ((info->loads[i]>>5) + 10);

                whole = tmp >> 11;
                fract = (((tmp & 0x7FF) * 100) >> 11);

                loads[i] = whole;
                loads[i] += ((float)fract / 100);

Frank Sweetser rasmusin at fsweetser at | PGP key available RedHat 5.1 kernel 2.1.106ac1 i586  | at public servers
"Note that if I can get you to "su and say" something just by asking,
you have a very serious security problem on your system and you should
look into it."
(By Paul Vixie, vixie-cron 3.0.1 installation notes)


1. Question about sysinfo load information

Can somebody shed some light on the load information returned by the sysinfo
function (I'm using RedHat 5.2)?  The 1, 5, and 15-minute load averages are
returned as unsigned long ints.  What are the units of measurement?  There is
no explanation whatsoever in the man page.  Please reply by email.

Boyana Radenska Norris

2. new linux user needs some help

3. sysinfo a new TCL/TK memory, swap and load average graph

4. Boot drive switch?

5. use of sysinfo() & load avg's...

6. Where to find WebDAV rpm package for Red Hat 6.2?

7. sysinfo load information

8. re.Linux Compatibilty

9. sysinfo question

10. Sysinfo problems on Ultra 30 box running Solaris 2.5.1

11. Problem with Sysinfo

12. magnicomp's sysinfo and device errors

13. sysinfo compatibility