Xref: utzoo comp.windows.x:19923 comp.sys.encore:552 Path: utzoo!attcan!uunet!mcsun!inria!irisa!presto.irisa.fr!hleroy From: hleroy@presto.irisa.fr (Hugues Leroy) Newsgroups: comp.windows.x,comp.sys.encore Subject: xcpustate for GOULD NP1 bi-processor Message-ID: <1990Mar19.174652.22710@irisa.fr> Date: 19 Mar 90 17:46:52 GMT Sender: news@irisa.fr Reply-To: hleroy@presto.irisa.fr (Hugues Leroy) Organization: Irisa, Rennes(FR) Lines: 171 This patches s.c and adds a new file s-gould-np1.c which draws 2 separate bars for the 2 cpus. Apply the patch file ( patch's.c.diff2' <<'END_OF_FILE' X*** s.c.orig Thu Mar 15 18:24:35 1990 X--- s.c Mon Mar 19 13:12:15 1990 X*************** X*** 20,25 **** X--- 20,30 ---- X # define s_included X #endif X X+ #ifdef GOULD_NP1 X+ # include "s-gould-np1.c" X+ # define s_included X+ #endif X+ X /* This should work on most BSD machines */ X #ifndef s_included X # include "s-bsd.c" END_OF_FILE if test 321 -ne `wc -c <'s.c.diff2'`; then echo shar: \"'s.c.diff2'\" unpacked with wrong size! fi # end of 's.c.diff2' fi if test -f 's-gould-np1.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'s-gould-np1.c'\" else echo shar: Extracting \"'s-gould-np1.c'\" \(2417 characters\) sed "s/^X//" >'s-gould-np1.c' <<'END_OF_FILE' X/* s-gould-np1.c : has _Cptime instead of _cp_time */ X X/* X * Hugues Leroy, INRIA, RENNES France X * added support for the Gould NP1 X * based on code by X * Chris Siebenmann, CSRI, University of Toronto X * and X * Salvador P. Abreu, U.Nova de Lisboa, PORTUGAL X*/ X X/* LINTLIBRARY */ X#include X#include X#include X Xextern int open(), read(); Xextern long lseek(); X X/* NPROCS is now always 2 */ X X#define NPROCS 2 X Xlong cp_time[NPROCS][CPUSTATES]; Xlong cp_old [NPROCS][CPUSTATES]; Xint kmem; /* file descriptor of /dev/kmem. */ Xstruct nlist nl[] = { X#define X_CP_TIME 0 X { "_Cptime" }, X { "" }, X}; X X/* Called at the beginning to inquire how many bars are needed. */ Xint Xnum_bars() X{ X return NPROCS; X} X X/* Called after num_bars to ask for the bar names */ X/* ARGSUSED */ Xchar ** Xlabel_bars(nbars) X{ X static char *name[NPROCS]; X X name[0] = "CPU 1"; X name[1] = "CPU 2"; X return name; X} X X/* X * Called after the bars are created to perform any machine dependent X * initializations. X */ X/* ARGSUSED */ Xvoid Xinit_bars(nbars) Xint nbars; X{ X X if ((kmem = open("/dev/kmem", 0)) < 0) { X perror("/dev/kmem"); X exit(1); X } X (void)nlist("/vmunix", nl); X if (lseek(kmem, (long) nl[X_CP_TIME].n_value, 0) != X (long) nl[X_CP_TIME].n_value) X perror("lseek"); X if (read(kmem, (char *) cp_old, sizeof(cp_old)) != X sizeof(cp_old)) X perror("read"); X} X X/* X * This procedure gets called every interval to compute and display the X * bars. It should call draw_bar() with the bar number, the array of X * integer values to display in the bar, and the number of values in X * the array. X */ X/* ARGSUSED */ Xvoid Xdisplay_bars(nbars) X{ X int states[CPUSTATES]; X int nstates; X int i,j; X X X if (lseek(kmem, (long) nl[X_CP_TIME].n_value, 0) != X (long) nl[X_CP_TIME].n_value) X perror("lseek"); X if (read(kmem, (char *) cp_time, sizeof(cp_time)) != X sizeof(cp_time)) X perror("read"); X X X#define delta(cpustate) ((int) (cp_time[i][(cpustate)] - cp_old[i][(cpustate)])) X X for (i=0; i