1: /*
   2:  * busy: print an indication of how busy the system is for games.
   3:  */
   4: #ifndef MAX
   5: # define MAX 30
   6: #endif
   7: 
   8: #include <stdio.h>
   9: main(argc, argv)
  10: char **argv;
  11: {
  12:     double la[3];
  13:     double max;
  14: 
  15:     loadav(la);
  16:     max = la[0];
  17:     if (la[1] > max) max = la[1];
  18:     if (la[2] > max) max = la[2];
  19:     if (argc > 1)
  20:         printf("1=%g, 5=%g, 15=%g, max=%g\n", la[0], la[1], la[2], max);
  21:     if (max > MAX)
  22:         printf("100\n");    /* incredibly high, no games allowed */
  23:     else
  24:         printf("0\n");
  25:     exit(0);
  26: }
  27: 
  28: #include <sys/types.h>
  29: #include <a.out.h>
  30: 
  31: struct  nlist nl[] = {
  32:     { "_avenrun" },
  33:     { 0 },
  34: };
  35: 
  36: loadav(avenrun)
  37: double  *avenrun;
  38: {
  39:     register int i;
  40:     int kmem;
  41: 
  42:     if ((kmem = open("/dev/kmem", 0)) < 0) {
  43:         fprintf(stderr, "No kmem\n");
  44:         exit(1);
  45:     }
  46:     nlist("/vmunix", nl);
  47:     if (nl[0].n_type==0) {
  48:         fprintf(stderr, "No namelist\n");
  49:         exit(1);
  50:     }
  51: 
  52:     lseek(kmem, (long)nl[0].n_value, 0);
  53:     read(kmem, avenrun, 3*sizeof(*avenrun));
  54: }

Defined functions

loadav defined in line 36; used 1 times
  • in line 15
main defined in line 9; never used

Defined variables

nl defined in line 31; used 3 times

Defined macros

MAX defined in line 5; used 2 times
  • in line 4, 21
Last modified: 1981-01-19
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 736
Valid CSS Valid XHTML 1.0 Strict