Xref: utzoo comp.windows.x:19816 comp.unix.ultrix:3008 Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uwm.edu!cs.utexas.edu!yale!mintaka!bloom-beacon!eru!luth!sunic!mcsun!inesc!unl!news From: spa@fctunl.rccn.pt (Salvador Pinto Abreu) Newsgroups: comp.windows.x,comp.unix.ultrix Subject: xcpustate for Ultrix multiprocessors Message-ID: Date: 14 Mar 90 19:58:39 GMT Sender: news@fctunl.rccn.pt (USENET News System) Organization: Universidade Nova de Lisboa -- Lisbon, Portugal Lines: 202 This patches s.c and adds a new file s-ultrix.c that draws separate bars for all the active processors on the system. Apply the patch file (patch s.c.diff <<'END_OF_s.c.diff' X*** /usr/users/sources/.backup/s.c Wed Mar 14 12:34:58 1990 X--- s.c Wed Mar 14 19:21:52 1990 X*************** X*** 15,20 **** X--- 15,25 ---- X # define s_included X #endif X X+ #ifdef ultrix X+ # include "s-ultrix.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_s.c.diff if test 337 -ne `wc -c s-ultrix.c <<'END_OF_s-ultrix.c' X/* X * System dependent file for BSD derivatives that have _cp_time in their X * kernels to hold the CPU states. Seen to work on SunOS and Ultrix. X */ X/* Salvador P. Abreu, U.Nova de Lisboa, PORTUGAL X based on code by X Chris Siebenmann, CSRI, University of Toronto */ X/* LINTLIBRARY */ X#include X#include X#include X#include X X#define kmseek(N) if (lseek(kmem, (long) (N), 0) != (long) (N)) perror ("lseek kmem"); X Xextern char *xmalloc(/* int nbytes */); X Xextern int open(), read(); Xextern long lseek(); X Xstruct cpudata *cpu_data = NULL; Xlong **cptime_old = NULL; X Xint kmem; /* file descriptor of /dev/kmem. */ Xstruct nlist nl[] = { X#define X_ACTIVECPU 0 X { "_activecpu" }, /* number of active CPUs */ X#define X_CPUDATA 1 X { "_cpudata" }, /* cpudata[] array */ X { 0 }, X}; X Xint activecpu; X X/* Called at the beginning to inquire how many bars are needed. */ Xint Xnum_bars() X{ X if ((kmem = open("/dev/kmem", 0)) < 0) { X perror("/dev/kmem"); X exit(1); X } X (void) nlist("/vmunix", nl); X X kmseek (nl[X_ACTIVECPU].n_value); X if (read (kmem, (char *) &activecpu, sizeof (activecpu)) != X sizeof (activecpu)) X perror ("read kmem"); X return (activecpu); X} X X/* Called after num_bars to ask for the bar names */ X/* ARGSUSED */ Xchar ** Xlabel_bars(nbars) X{ X static char **names; X static char hname[MAXHOSTNAMELEN]; X int i; X X names = (char **) malloc (nbars * sizeof (char *)); X for (i=0; i