|
|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T g
Length: 797 (0x31d)
Types: TextFile
Names: »getloadavg.c«
└─⟦9ae75bfbd⟧ Bits:30007242 EUUGD3: Starter Kit
└─⟦02f44f254⟧ »EurOpenD3/mail/sendmail.5.65.tar.Z«
└─⟦4e8d58309⟧
└─⟦this⟧ »./support/getloadavg.c«
/*
** GETLA -- get the current load average
**
** This code stolen from la.c.
**
** Parameters:
** none.
**
** Returns:
** The current load average as an integer.
**
** Side Effects:
** none.
*/
#include <sys/types.h>
#include <sys/ioctl.h>
#include <nlist.h>
struct nlist Nl[] =
{
{ "_avenrun" },
#define X_AVENRUN 0
{ 0 },
};
/* ARGSUSED */
getloadavg(avenrun, n)
double *avenrun;
int n;
{
static int kmem = -1;
extern off_t lseek();
if (kmem < 0) {
kmem = open("/dev/kmem", 0, 0);
if (kmem < 0)
return (-1);
(void) ioctl(kmem, (int) FIOCLEX, (char *) 0);
nlist("/vmunix", Nl);
if (Nl[0].n_type == 0)
return (-1);
}
if (lseek(kmem, (off_t) Nl[X_AVENRUN].n_value, 0) == -1 ||
read(kmem, (char *) avenrun, sizeof(avenrun)) < sizeof(avenrun))
return (-1);
}