source: trunk/athena/bin/mon/vm.c @ 2784

Revision 2784, 4.2 KB checked in by epeisach, 34 years ago (diff)
Decmips changes [jtkohl] Include proper header file, if display proper format.
Line 
1/*
2 *      $Source: /afs/dev.mit.edu/source/repository/athena/bin/mon/vm.c,v $
3 *      $Author: epeisach $
4 *      $Locker:  $
5 *      $Header: /afs/dev.mit.edu/source/repository/athena/bin/mon/vm.c,v 1.4 1990-03-26 15:39:30 epeisach Exp $
6 */
7
8#ifndef lint
9static char *rcsid_vm_c = "$Header: /afs/dev.mit.edu/source/repository/athena/bin/mon/vm.c,v 1.4 1990-03-26 15:39:30 epeisach Exp $";
10#endif  lint
11
12/*
13 *      V M
14 *
15 * Purpose:  Read the system virtual memory status info from kernel
16 *      space and write it onto the virtual screen used by curses(3).
17 *
18 * Bugs:  This routime (like the others) it does its own
19 *      printing.  This makes it very difficult to change the screen
20 *      format.  A better solution would be to move all the prints
21 *      into a screen update function.
22 */
23
24#include "mon.h"
25#ifdef ultrix
26#include <machine/param.h>      /* defines bytes/page */
27#else
28#include <machine/machparam.h>  /* defines bytes/page */
29#endif
30
31/* Temporary defines */
32#define PROCS   2
33#define CPUY    5
34#define TIMEY   8
35#define PAGE    11
36
37vm()
38{
39        register i,j;
40        long    t;              /* temporary */
41
42        lseek(kmem, (long)namelist[X_CP_TIME].n_value, 0);
43        read(kmem, s.cp_time, sizeof s.cp_time);
44        /* Check for 2nd CPU stats */
45        if (dualcpu) {
46                lseek(kmem, (long)namelist[X_CP_TIME2].n_value, 0);
47                read(kmem, s.cp_time2, sizeof s.cp_time2);
48        }
49        lseek(kmem, (long)namelist[X_DK_XFER].n_value, 0);
50        read(kmem, s.dk_xfer, sizeof s.dk_xfer);
51        lseek(kmem, (long)namelist[X_RATE].n_value, 0);
52        read(kmem, &rate, sizeof rate);
53        lseek(kmem, (long)namelist[X_TOTAL].n_value, 0);
54        read(kmem, &total, sizeof total);
55        lseek(kmem, (long)namelist[X_DEFICIT].n_value, 0);
56        read(kmem, &deficit, sizeof deficit);
57        etime = 0;
58        for (i=0; i < CPUSTATES; i++) {
59                t = s.cp_time[i];
60                s.cp_time[i] -= s1.cp_time[i];
61                s1.cp_time[i] = t;
62                if (dualcpu) {
63                        t = s.cp_time2[i];
64                        s.cp_time2[i] -= s1.cp_time2[i];
65                        s1.cp_time2[i] = t;
66                }
67                etime += s.cp_time[i];  /* interval must count 1 CPU only */
68        }
69        if(etime == 0.)
70                etime = 1.;
71        etime /= (float) hz;
72
73        /* Display the procs line */
74        mvprintw(PROCS+1,6,"%2d%2d%2d%2d %2d", total.t_rq, total.t_dw, total.t_pw, total.t_sw, total.t_sl);
75#define pgtok(a) ((a)*NBPG/1024)
76        mvprintw(PROCS+1,23,"%5d %5d", pgtok(total.t_rm), pgtok(total.t_arm) );
77        mvprintw(PROCS+1,34,"%6d %5d", pgtok(total.t_vm), pgtok(total.t_avm) );
78        mvprintw(PROCS+1,47,"%5d", pgtok(total.t_free));
79
80        /* Display paging info */
81        mvprintw(PAGE+1,6,"%4d %3d",
82                (rate.v_pgrec - (rate.v_xsfrec+rate.v_xifrec)),
83                (rate.v_xsfrec+rate.v_xifrec));
84        mvprintw(PAGE+1,14,"%4d %4d", pgtok(rate.v_pgpgin),
85                pgtok(rate.v_pgpgout));
86        /* operations per time is (pgin + pgout)  */
87        mvprintw(PAGE+1,24,"%4d", (pgtok(rate.v_pgin)+
88                pgtok(rate.v_pgout)));
89        mvprintw(PAGE+1,29,"%4d %4d %4d", pgtok(rate.v_dfree)
90                , pgtok(deficit), rate.v_scan);
91
92        /* Display CPU info */
93        mvprintw(CPUY+1,4,"%4d  %4d",
94#if defined(vax) || defined(mips)
95        (rate.v_intr) - hz, rate.v_syscall);
96#endif
97#if defined(sun) || defined(ibm032)
98        rate.v_intr, rate.v_syscall);
99#endif
100/* if not vax, mips, sun or ibm, a syntax error will result */
101        mvprintw(CPUY+1,17,"%4d", rate.v_swtch);
102        cputime();
103
104        /* Display additional stuff */
105        mvprintw(PAGE+4,6,"%4d%4d %4d%4d %4d%4d %4d %4d%4d",
106                rate.v_nexfod, rate.v_exfod,
107                rate.v_nzfod, rate.v_zfod,
108                rate.v_nvrfod, rate.v_vrfod,
109                rate.v_pgfrec,
110                rate.v_swpin, rate.v_swpout);
111}
112
113
114/*
115 * Display cpu time info (%time in each state)
116 */
117cputime()
118{
119        int x;
120        double t, t2;
121        register i;
122
123        t = t2 = 0;
124        for(i=0; i<CPUSTATES; i++) {
125                t += s.cp_time[i];
126                t2 += s.cp_time2[i];
127        }
128        if(t == 0.)
129                t = 1.;
130        if (t2 == 0.)
131                t2 = 1.;
132        x = 6;
133        for(i=0; i<CPUSTATES; i++){
134                mvprintw(TIMEY+1,x,"%3.0f", 100 * s.cp_time[i]/t);
135                if (dualcpu)
136                        mvprintw(TIMEY+1,x+27,"%3.0f", 100 * s.cp_time2[i]/t2);
137                x += 5;
138        }
139}
Note: See TracBrowser for help on using the repository browser.