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