Annotation of researchv9/jerq/src/sysmon/sampleload.c, revision 1.1

1.1     ! root        1: #include <stdio.h>
        !             2: #include <errno.h>
        !             3: #include <nlist.h>
        !             4: #include "defs.h"
        !             5: #include "load.h"
        !             6: 
        !             7: /* globals */
        !             8: struct nlist nl[] ={
        !             9:     {"_intrtime",0},
        !            10:     {"_cp_time",0},
        !            11:     {"_avenrun",0},
        !            12:     { 0,0 },
        !            13: };
        !            14: char *sys = "/unix";
        !            15: char *core = "/dev/kmem";
        !            16: int mem;
        !            17: 
        !            18: /* imported */
        !            19: extern int errno;
        !            20: extern long lseek();
        !            21: extern long time();
        !            22: 
        !            23: /* initialize */
        !            24: initload()
        !            25: {
        !            26:     nlist(sys, nl);
        !            27: 
        !            28:     mem = open(core, 0);
        !            29:     if (mem<0) {
        !            30:        printf("can't open %s\n", core);
        !            31:        printf("errno = %d\n", errno);
        !            32:        exit(1);
        !            33:     }
        !            34: 
        !            35: }
        !            36: 
        !            37: /* generate the current information */
        !            38: genload()
        !            39: {
        !            40:     char buf[16];
        !            41:     double fabs();
        !            42: 
        !            43:     lseek(mem, (long)nl[1].n_value, 0);
        !            44:     read(mem, (char *)load.l_cp, sizeof(load.l_cp));
        !            45:     lseek(mem, (long)nl[2].n_value, 0);
        !            46:     read(mem, (char *)&(load.l_runq), sizeof(load.l_runq));
        !            47:     load.l_time = time ((long *)0);
        !            48: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.