1: /*
   2:  * Copyright (c) 1980 Regents of the University of California.
   3:  * All rights reserved.  The Berkeley software License Agreement
   4:  * specifies the terms and conditions for redistribution.
   5:  */
   6: 
   7: #ifndef lint
   8: static char sccsid[] = "@(#)busy.c	5.1 (Berkeley) 5/30/85";
   9: #endif not lint
  10: 
  11: /*
  12:  * busy: print an indication of how busy the system is for games.
  13:  */
  14: #ifndef MAX
  15: # define MAX 30
  16: #endif
  17: 
  18: #include <stdio.h>
  19: main(argc, argv)
  20: char **argv;
  21: {
  22:     double la[3];
  23:     double max;
  24: 
  25:     loadav(la);
  26:     max = la[0];
  27:     if (la[1] > max) max = la[1];
  28:     if (la[2] > max) max = la[2];
  29:     if (argc > 1)
  30:         printf("1=%g, 5=%g, 15=%g, max=%g\n", la[0], la[1], la[2], max);
  31:     if (max > MAX)
  32:         printf("100\n");    /* incredibly high, no games allowed */
  33:     else
  34:         printf("0\n");
  35:     exit(0);
  36: }
  37: 
  38: #include <sys/types.h>
  39: #include <a.out.h>
  40: 
  41: struct  nlist nl[] = {
  42:     { "_avenrun" },
  43:     { 0 },
  44: };
  45: 
  46: loadav(avenrun)
  47: double  *avenrun;
  48: {
  49:     register int i;
  50:     int kmem;
  51: 
  52:     if ((kmem = open("/dev/kmem", 0)) < 0) {
  53:         fprintf(stderr, "No kmem\n");
  54:         exit(1);
  55:     }
  56:     nlist("/vmunix", nl);
  57:     if (nl[0].n_type==0) {
  58:         fprintf(stderr, "No namelist\n");
  59:         exit(1);
  60:     }
  61: 
  62:     lseek(kmem, (long)nl[0].n_value, 0);
  63:     read(kmem, avenrun, 3*sizeof(*avenrun));
  64: }

Defined functions

loadav defined in line 46; used 1 times
  • in line 25
main defined in line 19; never used

Defined variables

nl defined in line 41; used 3 times
sccsid defined in line 8; never used

Defined macros

MAX defined in line 15; used 2 times
Last modified: 1985-05-30
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1015
Valid CSS Valid XHTML 1.0 Strict