1: #include <stdio.h>
   2: #include <nlist.h>
   3: #include <signal.h>
   4: #include <sys/trace.h>
   5: 
   6: struct  nlist nl[] =
   7:     {
   8:     { "_tracebuf" },
   9:     { "" },
  10:     };
  11: 
  12:     int mf, hdr(), lines = 1;
  13: 
  14: main(argc, argv)
  15:     int argc;
  16:     char **argv;
  17:     {
  18:     register i;
  19:     int iter;
  20: 
  21:     nlist("/vmunix", nl);
  22:     if  (nl[0].n_type == 0)
  23:         {
  24:         fprintf(stderr, "no /vmunix namelist\n");
  25:         exit(1);
  26:     }
  27:     mf = open("/dev/kmem", 0);
  28:     if  (mf < 0)
  29:         {
  30:         fprintf(stderr, "cannot open /dev/kmem\n");
  31:         exit(1);
  32:         }
  33:     iter = 0;
  34:     argc--, argv++;
  35:     if  (argc > 1)
  36:         iter = atoi(argv[1]);
  37:     signal(SIGCONT, hdr);
  38: loop:
  39:     if  (--lines == 0)
  40:         hdr();
  41:     nmstats();
  42:     fflush(stdout);
  43:     if  (--iter &&argc > 0)
  44:         {
  45:         sleep(atoi(argv[0]));
  46:         goto loop;
  47:         }
  48:     }
  49: 
  50: hdr()
  51:     {
  52: 
  53:     puts("bhit      bmiss     bwrite    bhitra    bmissra   brelse    %bhit");
  54:     lines = 19;
  55:     }
  56: 
  57: nmstats()
  58:     {
  59:     float   pct;
  60:     long    tracebuf[TR_NUM_210];
  61: 
  62:     lseek(mf, (long)nl[0].n_value, 0);
  63:     read(mf, tracebuf, sizeof tracebuf);
  64:     pct = tracebuf[TR_BREADHIT];
  65:     pct /= (tracebuf[TR_BREADHIT] + tracebuf[TR_BREADMISS]);
  66:     pct *= 100.0;
  67:     printf("%-9D %-9D %-9D %-9D %-9D %-9D %.2f\n",
  68:         tracebuf[TR_BREADHIT],
  69:         tracebuf[TR_BREADMISS],
  70:         tracebuf[TR_BWRITE],
  71:         tracebuf[TR_BREADHITRA],
  72:         tracebuf[TR_BREADMISSRA],
  73:         tracebuf[TR_BRELSE],
  74:         pct);
  75:     }

Defined functions

hdr defined in line 50; used 3 times
main defined in line 14; never used
nmstats defined in line 57; used 1 times
  • in line 41

Defined variables

lines defined in line 12; used 2 times
mf defined in line 12; used 4 times
nl defined in line 6; used 3 times
Last modified: 1991-06-29
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 3461
Valid CSS Valid XHTML 1.0 Strict