1 | /* |
---|
2 | * $Source: /afs/dev.mit.edu/source/repository/athena/bin/mon/vm.c,v $ |
---|
3 | * $Author: builder $ |
---|
4 | * $Locker: $ |
---|
5 | * $Header: /afs/dev.mit.edu/source/repository/athena/bin/mon/vm.c,v 1.2 1985-11-13 00:05:10 builder Exp $ |
---|
6 | */ |
---|
7 | |
---|
8 | #ifndef lint |
---|
9 | static char *rcsid_vm_c = "$Header: /afs/dev.mit.edu/source/repository/athena/bin/mon/vm.c,v 1.2 1985-11-13 00:05:10 builder 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 | #include <machine/machparam.h> /* defines bytes/page */ |
---|
26 | |
---|
27 | /* Temporary defines */ |
---|
28 | #define PROCS 2 |
---|
29 | #define CPUY 5 |
---|
30 | #define TIMEY 8 |
---|
31 | #define PAGE 11 |
---|
32 | |
---|
33 | vm() |
---|
34 | { |
---|
35 | register i,j; |
---|
36 | long t; /* temporary */ |
---|
37 | |
---|
38 | lseek(kmem, (long)namelist[X_CP_TIME].n_value, 0); |
---|
39 | read(kmem, s.cp_time, sizeof s.cp_time); |
---|
40 | /* Check for 2nd CPU stats */ |
---|
41 | if (dualcpu) { |
---|
42 | lseek(kmem, (long)namelist[X_CP_TIME2].n_value, 0); |
---|
43 | read(kmem, s.cp_time2, sizeof s.cp_time2); |
---|
44 | } |
---|
45 | lseek(kmem, (long)namelist[X_DK_XFER].n_value, 0); |
---|
46 | read(kmem, s.dk_xfer, sizeof s.dk_xfer); |
---|
47 | lseek(kmem, (long)namelist[X_RATE].n_value, 0); |
---|
48 | read(kmem, &rate, sizeof rate); |
---|
49 | lseek(kmem, (long)namelist[X_TOTAL].n_value, 0); |
---|
50 | read(kmem, &total, sizeof total); |
---|
51 | lseek(kmem, (long)namelist[X_DEFICIT].n_value, 0); |
---|
52 | read(kmem, &deficit, sizeof deficit); |
---|
53 | etime = 0; |
---|
54 | for (i=0; i < CPUSTATES; i++) { |
---|
55 | t = s.cp_time[i]; |
---|
56 | s.cp_time[i] -= s1.cp_time[i]; |
---|
57 | s1.cp_time[i] = t; |
---|
58 | if (dualcpu) { |
---|
59 | t = s.cp_time2[i]; |
---|
60 | s.cp_time2[i] -= s1.cp_time2[i]; |
---|
61 | s1.cp_time2[i] = t; |
---|
62 | } |
---|
63 | etime += s.cp_time[i]; /* interval must count 1 CPU only */ |
---|
64 | } |
---|
65 | if(etime == 0.) |
---|
66 | etime = 1.; |
---|
67 | etime /= (float) hz; |
---|
68 | |
---|
69 | /* Display the procs line */ |
---|
70 | mvprintw(PROCS+1,6,"%2d%2d%2d%2d %2d", total.t_rq, total.t_dw, total.t_pw, total.t_sw, total.t_sl); |
---|
71 | #define pgtok(a) ((a)*NBPG/1024) |
---|
72 | mvprintw(PROCS+1,23,"%5d %5d", pgtok(total.t_rm), pgtok(total.t_arm) ); |
---|
73 | mvprintw(PROCS+1,34,"%6d %5d", pgtok(total.t_vm), pgtok(total.t_avm) ); |
---|
74 | mvprintw(PROCS+1,47,"%5d", pgtok(total.t_free)); |
---|
75 | |
---|
76 | /* Display paging info */ |
---|
77 | mvprintw(PAGE+1,6,"%4d %3d", |
---|
78 | (rate.v_pgrec - (rate.v_xsfrec+rate.v_xifrec)), |
---|
79 | (rate.v_xsfrec+rate.v_xifrec)); |
---|
80 | mvprintw(PAGE+1,14,"%4d %4d", pgtok(rate.v_pgpgin), |
---|
81 | pgtok(rate.v_pgpgout)); |
---|
82 | /* operations per time is (pgin + pgout) */ |
---|
83 | mvprintw(PAGE+1,24,"%4d", (pgtok(rate.v_pgin)+ |
---|
84 | pgtok(rate.v_pgout))); |
---|
85 | mvprintw(PAGE+1,29,"%4d %4d %4d", pgtok(rate.v_dfree) |
---|
86 | , pgtok(deficit), rate.v_scan); |
---|
87 | |
---|
88 | /* Display CPU info */ |
---|
89 | mvprintw(CPUY+1,4,"%4d %4d", (rate.v_intr) - hz, rate.v_syscall); |
---|
90 | mvprintw(CPUY+1,17,"%4d", rate.v_swtch); |
---|
91 | cputime(); |
---|
92 | |
---|
93 | /* Display additional stuff */ |
---|
94 | mvprintw(PAGE+4,6,"%4d%4d %4d%4d %4d%4d %4d %4d%4d", |
---|
95 | rate.v_nexfod, rate.v_exfod, |
---|
96 | rate.v_nzfod, rate.v_zfod, |
---|
97 | rate.v_nvrfod, rate.v_vrfod, |
---|
98 | rate.v_pgfrec, |
---|
99 | rate.v_swpin, rate.v_swpout); |
---|
100 | } |
---|
101 | |
---|
102 | |
---|
103 | /* |
---|
104 | * Display cpu time info (%time in each state) |
---|
105 | */ |
---|
106 | cputime() |
---|
107 | { |
---|
108 | int x; |
---|
109 | double t, t2; |
---|
110 | register i; |
---|
111 | |
---|
112 | t = t2 = 0; |
---|
113 | for(i=0; i<CPUSTATES; i++) { |
---|
114 | t += s.cp_time[i]; |
---|
115 | t2 += s.cp_time2[i]; |
---|
116 | } |
---|
117 | if(t == 0.) |
---|
118 | t = 1.; |
---|
119 | if (t2 == 0.) |
---|
120 | t2 = 1.; |
---|
121 | x = 6; |
---|
122 | for(i=0; i<CPUSTATES; i++){ |
---|
123 | mvprintw(TIMEY+1,x,"%3.0f", 100 * s.cp_time[i]/t); |
---|
124 | if (dualcpu) |
---|
125 | mvprintw(TIMEY+1,x+27,"%3.0f", 100 * s.cp_time2[i]/t2); |
---|
126 | x += 5; |
---|
127 | } |
---|
128 | } |
---|