Back to index

glibc  2.9
getloadavg.c File Reference
#include <mach.h>
#include <mach/host_info.h>
#include <hurd.h>
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>

Go to the source code of this file.


int getloadavg (double loadavg[], int nelem)

Function Documentation

int getloadavg ( double  loadavg[],
int  nelem 

Definition at line 34 of file getloadavg.c.

  host_load_info_data_t info;
  mach_msg_type_number_t size = HOST_LOAD_INFO_COUNT;
  error_t err;
  int i;

  err = __host_info (__mach_host_self (), HOST_LOAD_INFO,
                   (host_info_t) &info, &size);
  if (err)
    return __hurd_fail (err);
  if (size < HOST_LOAD_INFO_COUNT)
    return __hurd_fail (EGRATUITOUS);

  if (nelem > 3)
    nelem = 3;
  for (i = 0; i < nelem; ++i)
    loadavg[i] = (double) info.avenrun[i] / (double) LOAD_SCALE;

  return i;

Here is the call graph for this function: