[comp.sources.x] v06i026: xcpustate, Part01/01

argv%turnpike@Sun.COM (Dan Heller) (03/11/90)

Submitted-by: Mark Moraes <moraes@cs.toronto.edu>
Posting-number: Volume 6, Issue 26
Archive-name: xcpustate/part01



Uses dithered gray bars to monitor instantaneous CPU states;  it has
drivers for BSD systems (SunOS, Ultrix, etc), and multiprocessor
SGI Iris4ds and Cray1s.

It is already at patchlevel 2, and has been seen to work on R3 once
upon a long ago and R4 now.  (Needs the R4 include file organization --
X11/Xaw/,X11/Xmu/ etc.)

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, use "sh file -c".
# If this archive is complete, you will see the following message at the end:
#		"End of shell archive."
#
# Contents:
#   xcpustate xcpustate/BUGS xcpustate/Bar.c xcpustate/Bar.h
#   xcpustate/BarP.h xcpustate/CHANGES.Pat01 xcpustate/CHANGES.Pat02
#   xcpustate/COPYRIGHT xcpustate/Imakefile xcpustate/Makefile
#   xcpustate/README xcpustate/patchlevel.h xcpustate/s-bsd.c
#   xcpustate/s-cray-xmp.c xcpustate/s-iris4d.c xcpustate/s.c
#   xcpustate/s.h xcpustate/xcpustate.c xcpustate/xcpustate.man
#
# Wrapped by moraes@cs.utoronto.ca on Sat Mar 10 16:37:29 1990
#
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test ! -d xcpustate ; then
    echo shar: Creating directory \"xcpustate\"
    mkdir xcpustate
fi
if test -f xcpustate/BUGS -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"xcpustate/BUGS\"
else
echo shar: Extracting \"xcpustate/BUGS\" \(55 characters\)
sed "s/^X//" >xcpustate/BUGS <<'END_OF_xcpustate/BUGS'
XResizing it vertically causes havoc, I'm not sure why.
END_OF_xcpustate/BUGS
if test 55 -ne `wc -c <xcpustate/BUGS`; then
    echo shar: \"xcpustate/BUGS\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f xcpustate/Bar.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"xcpustate/Bar.c\"
else
echo shar: Extracting \"xcpustate/Bar.c\" \(8007 characters\)
sed "s/^X//" >xcpustate/Bar.c <<'END_OF_xcpustate/Bar.c'
X#include <X11/copyright.h>
X
X/* $XConsortium: Bar.c,v 1.2 88/10/25 17:40:25 swick Exp $ */
X/* Copyright	Massachusetts Institute of Technology	1987, 1988 */
X
X#include <X11/IntrinsicP.h>
X#include <X11/StringDefs.h>
X#include "BarP.h"
X
Xstatic Dimension def_dimension	= ~0;
Xstatic XtOrientation def_orient = XtorientHorizontal;
X#define DEF_LENGTH  ((Dimension) 200)
X#define DEF_THICKNESS	((Dimension) 15)
X
Xstatic XtResource resources[] = {
X#define offset(field) XtOffset(BarWidget, bar.field)
X#define Offset(field) XtOffset(BarWidget, field)
X    /* {name, class, type, size, offset, default_type, default_addr}, */
X    /*
X     * We define these core class values to set defaults, so we can
X     * initialize correctly
X     */
X    {XtNwidth, XtCWidth, XtRDimension, sizeof(Dimension),
X	Offset(core.width), XtRDimension, (caddr_t)&def_dimension},
X    {XtNheight, XtCHeight, XtRDimension, sizeof(Dimension),
X	Offset(core.height), XtRDimension, (caddr_t)&def_dimension},
X    /* Private bar widget resources */
X    {XtNlength, XtCLength, XtRDimension, sizeof(Dimension),
X	offset(length), XtRDimension, (caddr_t) &def_dimension},
X    {XtNthickness, XtCThickness, XtRDimension, sizeof(Dimension),
X	offset(thickness), XtRDimension, (caddr_t) &def_dimension},
X    {XtNorientation, XtCOrientation, XtROrientation, sizeof(XtOrientation),
X	offset(orientation), XtROrientation, (caddr_t) &def_orient},
X#undef offset
X#undef Offset
X};
X
Xstatic void ClassInitialize();
Xstatic void Initialize();
Xstatic void Resize();
Xstatic void Redisplay();
X
XBarClassRec barClassRec = {
X  { /* core fields */
X    /* superclass		*/	(WidgetClass) &widgetClassRec,
X    /* class_name		*/	"Bar",
X    /* widget_size		*/	sizeof(BarRec),
X    /* class_initialize		*/	ClassInitialize,
X    /* class_part_initialize	*/	NULL,
X    /* class_inited		*/	FALSE,
X    /* initialize		*/	Initialize,
X    /* initialize_hook		*/	NULL,
X    /* realize			*/	XtInheritRealize,
X    /* actions			*/	NULL,
X    /* num_actions		*/	0,
X    /* resources		*/	resources,
X    /* num_resources		*/	XtNumber(resources),
X    /* xrm_class		*/	NULLQUARK,
X    /* compress_motion		*/	TRUE,
X    /* compress_exposure	*/	TRUE,
X    /* compress_enterleave	*/	TRUE,
X    /* visible_interest		*/	FALSE,
X    /* destroy			*/	NULL,
X    /* resize			*/	Resize,
X    /* expose			*/	Redisplay,
X    /* set_values		*/	NULL,
X    /* set_values_hook		*/	NULL,
X    /* set_values_almost	*/	XtInheritSetValuesAlmost,
X    /* get_values_hook		*/	NULL,
X    /* accept_focus		*/	NULL,
X    /* version			*/	XtVersion,
X    /* callback_private		*/	NULL,
X    /* tm_table			*/	NULL,
X    /* query_geometry		*/	XtInheritQueryGeometry,
X    /* display_accelerator	*/	XtInheritDisplayAccelerator,
X    /* extension		*/	NULL
X  },
X  { /* bar fields */
X    /* gray			*/	NULL
X  }
X};
X
XWidgetClass barWidgetClass = (WidgetClass)&barClassRec;
X
Xstatic char gray0_bits[] = {
X   0x00, 0x00, 0x00};
Xstatic char gray1_bits[] = {
X   0x00, 0x02, 0x00};
Xstatic char gray2_bits[] = {
X   0x00, 0x03, 0x00};
Xstatic char gray3_bits[] = {
X   0x00, 0x03, 0x02};
Xstatic char gray4_bits[] = {
X   0x00, 0x07, 0x02};
Xstatic char gray5_bits[] = {
X   0x04, 0x07, 0x02};
Xstatic char gray6_bits[] = {
X   0x04, 0x07, 0x03};
Xstatic char gray7_bits[] = {
X   0x05, 0x07, 0x03};
Xstatic char gray8_bits[] = {
X   0x05, 0x07, 0x07};
Xstatic char gray9_bits[] = {
X   0xff, 0xff, 0xff};
X
Xstatic char *gray_bits[MAXGRAY] = {
X    gray0_bits,
X    gray1_bits,
X    gray2_bits,
X    gray3_bits,
X    gray4_bits,
X    gray5_bits,
X    gray6_bits,
X    gray7_bits,
X    gray8_bits,
X    gray9_bits,
X};
X
Xstatic void
XClassInitialize()
X{
X    XtAddConverter( XtRString, XtROrientation, XmuCvtStringToOrientation,
X		    NULL, (Cardinal)0 );
X}
X
Xstatic void
XSetDimensions(w)
XBarWidget w;
X{
X    if (w->bar.orientation == XtorientVertical) {
X	w->bar.length = w->core.height;
X	w->bar.thickness = w->core.width;
X    }
X    else {
X	w->bar.length = w->core.width;
X	w->bar.thickness = w->core.height;
X    }
X}
X
X/* ARGSUSED */
Xstatic void
XInitialize(request, new)
XWidget request;		/* what the client asked for */
XWidget new;		/* what we're going to give him */
X{
X    BarWidget w = (BarWidget) new;
X    XGCValues gcValues;
X    BarClassPart *bcp = &(barClassRec.bar_class);
X    int i;
X
X    if (bcp->gray == (Pixmap *) NULL) {
X	/*
X	 *  We initialize this here instead of ClassInitialize because
X	 *  we need a window to initialize this in. A cleaner way to do
X	 *  this would be to use a separate set of Pixmaps for each
X	 *  widget, so that widgets can be on different screen/visuals.
X	 *  But then we'd have to fix it so this thing understood
X	 *  colours, visuals, more resources...  Laziness wins.
X	 */
X	bcp->gray = (Pixmap *) XtMalloc(MAXGRAY * sizeof(Pixmap));
X	for(i = 0; i < MAXGRAY; i++) {
X	    bcp->gray[i] = XCreatePixmapFromBitmapData(XtDisplay(new),
X	     DefaultRootWindow(XtDisplay(new)), gray_bits[i], 3, 3,
X	     WhitePixelOfScreen(XtScreen(new)),
X	     BlackPixelOfScreen(XtScreen(new)), 1);
X	}
X    }
X    gcValues.stipple = bcp->gray[0];
X    gcValues.fill_style = FillOpaqueStippled;
X    w->bar.gc = XCreateGC(XtDisplay(new), DefaultRootWindow(XtDisplay(new)),
X     GCFillStyle | GCStipple, &gcValues);
X    /* Width and height override length and thickness */
X    if (w->bar.length == def_dimension)
X	w->bar.length = DEF_LENGTH;
X	
X    if (w->bar.thickness == def_dimension)
X	w->bar.thickness = DEF_THICKNESS;
X	
X    if (w->core.width == def_dimension)
X	w->core.width = (w->bar.orientation == XtorientVertical)
X	    ? w->bar.thickness : w->bar.length;
X
X    if (w->core.height == def_dimension)
X	w->core.height = (w->bar.orientation == XtorientHorizontal)
X	    ? w->bar.thickness : w->bar.length;
X    w->bar.values = NULL;
X    w->bar.nvalues = 0;
X
X    SetDimensions(w);
X}
X
X/* ARGSUSED */
Xstatic void
XResize(gw)
XWidget gw;
X{
X    SetDimensions((BarWidget)gw);
X    Redisplay(gw, (XEvent*)NULL, (Region)NULL);
X}
X
X/* ARGSUSED */
Xstatic void
XRedisplay(gw, event, region)
XWidget gw;
XXEvent *event;
XRegion region;
X{
X    BarWidget w = (BarWidget) gw;
X    int x, y;
X    unsigned int width, height;
X    int maxvalue, i;
X    int inc_gray;
X    int igray; 
X    int vertical = (w->bar.orientation == XtorientVertical);;
X
X    if (! XtIsRealized(gw))
X	return;
X    for(maxvalue = 0, i = 0; i < w->bar.nvalues; i++)
X	maxvalue += w->bar.values[i];
X    if(maxvalue <= 0)
X	return;
X    x = y = 0;
X    if(vertical)
X	width = w->bar.thickness;
X    else
X	height = w->bar.thickness;
X    inc_gray = (w->bar.nvalues > 1) ? (MAXGRAY - 1) / (w->bar.nvalues - 1) :
X	MAXGRAY - 1;
X    for(igray = 0, i = 0; i < w->bar.nvalues; i++, igray += inc_gray) {
X	unsigned int rectlen = (w->bar.length * w->bar.values[i] +
X				maxvalue / 2) / maxvalue;
X	if (rectlen == 0)
X	    continue;
X	if (i == w->bar.nvalues - 1) {
X	    if (vertical)
X		rectlen = w->core.height - y;
X	    else
X		rectlen = w->core.width - x;
X	}
X	XSetStipple(XtDisplay(gw), w->bar.gc, barClassRec.bar_class.gray[igray]);
X	if(vertical) {
X	    XFillRectangle(XtDisplay(gw), XtWindow(gw), w->bar.gc,
X	     x, y, width, rectlen);
X	    y += rectlen;
X	} else {
X	    XFillRectangle(XtDisplay(gw), XtWindow(gw), w->bar.gc,
X	     x, y, rectlen, height);
X	    x += rectlen;
X	}
X    }
X}
X
X/* Public routines. */
Xvoid
XSetBarValues(gw, values, nvalues)
XWidget gw;
Xint *values;
Xint nvalues;
X{
X    BarWidget w = (BarWidget) gw;
X    int i;
X
X    if (nvalues > MAXGRAY) {
X#define ERRFMT "Tried to set %d values for bar - maximum is %d\n"
X	char errbuf[sizeof(ERRFMT) + 32];
X	(void) sprintf(errbuf, ERRFMT, nvalues, MAXGRAY);
X#undef ERRFMT
X	XtWarning(errbuf);
X	nvalues = MAXGRAY;
X    }
X    if (nvalues < 0) {
X#define ERRFMT "Tried to set %d values for bar - it must be > 0\n"
X	char errbuf[sizeof(ERRFMT) + 32];
X	(void) sprintf(errbuf, ERRFMT, nvalues);
X	XtWarning(errbuf);
X#undef ERRFMT
X	return;
X    }
X    w->bar.nvalues = nvalues;
X    if (w->bar.values != NULL)
X	XtFree((char *) w->bar.values);
X    if (nvalues != 0)
X	w->bar.values = (int *) XtMalloc(nvalues * sizeof(int));
X    for(i = 0; i < nvalues; i++)
X	w->bar.values[i] = values[i];
X    Redisplay( gw, (XEvent*)NULL, (Region)NULL );
X}
END_OF_xcpustate/Bar.c
if test 8007 -ne `wc -c <xcpustate/Bar.c`; then
    echo shar: \"xcpustate/Bar.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f xcpustate/Bar.h -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"xcpustate/Bar.h\"
else
echo shar: Extracting \"xcpustate/Bar.h\" \(1187 characters\)
sed "s/^X//" >xcpustate/Bar.h <<'END_OF_xcpustate/Bar.h'
X#include <X11/copyright.h>
X
X/* $XConsortium: Bar.h,v 1.2 88/10/25 17:22:09 swick Exp $ */
X/* Copyright	Massachusetts Institute of Technology	1987, 1988 */
X
X#ifndef _Bar_h
X#define _Bar_h
X
X/****************************************************************
X *
X * Bar widget
X *
X ****************************************************************/
X
X/* Resources:
X
X Name		     Class		RepType		Default Value
X ----		     -----		-------		-------------
X background	     Background		Pixel		XtDefaultBackground
X border		     BorderColor	Pixel		XtDefaultForeground
X borderWidth	     BorderWidth	Dimension	1
X destroyCallback     Callback		Pointer		NULL
X height		     Height		Dimension	0
X mappedWhenManaged   MappedWhenManaged	Boolean		True
X sensitive	     Sensitive		Boolean		True
X width		     Width		Dimension	0
X x		     Position		Position	0
X y		     Position		Position	0
X
X*/
X
X/* declare specific BarWidget class and instance datatypes */
X
Xtypedef struct _BarClassRec*	BarWidgetClass;
Xtypedef struct _BarRec*		BarWidget;
X
X/* declare the class constant */
X
Xextern WidgetClass barWidgetClass;
X
X/* Public procedures */
Xextern void SetBarValues(/* BarWidget w, int *values, int nvalues */);
X
X#endif  _Bar_h
END_OF_xcpustate/Bar.h
if test 1187 -ne `wc -c <xcpustate/Bar.h`; then
    echo shar: \"xcpustate/Bar.h\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f xcpustate/BarP.h -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"xcpustate/BarP.h\"
else
echo shar: Extracting \"xcpustate/BarP.h\" \(1046 characters\)
sed "s/^X//" >xcpustate/BarP.h <<'END_OF_xcpustate/BarP.h'
X#include <X11/copyright.h>
X
X/* $XConsortium: BarP.h,v 1.2 88/10/25 17:37:59 swick Exp $ */
X/* Copyright	Massachusetts Institute of Technology	1987, 1988 */
X
X#ifndef _BarP_h
X#define _BarP_h
X
X#include <X11/Xmu/Xmu.h>
X#include "Bar.h"
X/* include superclass private header file */
X#include <X11/CoreP.h>
X
X/* define unique representation types not found in <X11/StringDefs.h> */
X
X#define MAXGRAY 10
X
Xtypedef struct {
X    Pixmap *gray;
X} BarClassPart;
X
Xtypedef struct _BarClassRec {
X    CoreClassPart	core_class;
X    BarClassPart	bar_class;
X} BarClassRec;
X
Xextern BarClassRec barClassRec;
X
Xtypedef struct {
X    /* private state */
X    int *values;		/* Array of values displayed in bar */
X    int nvalues;		/* Number of elements in values */
X    XtOrientation orientation;	/* XtorientHorizontal or XtorientVertical */
X    Dimension	  length;	/* either height or width */
X    Dimension	  thickness;	/* either width or height */
X    GC		  gc;		/* a gc */
X} BarPart;
X
Xtypedef struct _BarRec {
X    CorePart	core;
X    BarPart	bar;
X} BarRec;
X
X#endif  _BarP_h
END_OF_xcpustate/BarP.h
if test 1046 -ne `wc -c <xcpustate/BarP.h`; then
    echo shar: \"xcpustate/BarP.h\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f xcpustate/CHANGES.Pat01 -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"xcpustate/CHANGES.Pat01\"
else
echo shar: Extracting \"xcpustate/CHANGES.Pat01\" \(305 characters\)
sed "s/^X//" >xcpustate/CHANGES.Pat01 <<'END_OF_xcpustate/CHANGES.Pat01'
X- puts the hostname in the bar for s-bsd.
X
X- system file for Cray XMP systems from Walter Poxon <wdp@zeus.cray.com>
X  Thanks.  (I haven't a Cray to test this, alas:-)
X
X- uses stippling instead of tiling to avoid hallucinogenic effects
X  on colour displays
X
X- uses the R4 include and Imakefile conventions
END_OF_xcpustate/CHANGES.Pat01
if test 305 -ne `wc -c <xcpustate/CHANGES.Pat01`; then
    echo shar: \"xcpustate/CHANGES.Pat01\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f xcpustate/CHANGES.Pat02 -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"xcpustate/CHANGES.Pat02\"
else
echo shar: Extracting \"xcpustate/CHANGES.Pat02\" \(143 characters\)
sed "s/^X//" >xcpustate/CHANGES.Pat02 <<'END_OF_xcpustate/CHANGES.Pat02'
X- file s-cray-xmp.c got left out of patch1, sigh.  Also a fix to xcpustate.c
X  and s.c to make them compile on a Cray (thanks to dac@cray.com)
END_OF_xcpustate/CHANGES.Pat02
if test 143 -ne `wc -c <xcpustate/CHANGES.Pat02`; then
    echo shar: \"xcpustate/CHANGES.Pat02\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f xcpustate/COPYRIGHT -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"xcpustate/COPYRIGHT\"
else
echo shar: Extracting \"xcpustate/COPYRIGHT\" \(915 characters\)
sed "s/^X//" >xcpustate/COPYRIGHT <<'END_OF_xcpustate/COPYRIGHT'
X/*
X * Copyright University of Toronto 1988, 1989.
X * Written by Mark Moraes
X *
X * Permission is granted to anyone to use this software for any purpose on
X * any computer system, and to alter it and redistribute it freely, subject
X * to the following restrictions:
X *
X * 1. The author and the University of Toronto are not responsible 
X *    for the consequences of use of this software, no matter how awful, 
X *    even if they arise from flaws in it.
X *
X * 2. The origin of this software must not be misrepresented, either by
X *    explicit claim or by omission.  Since few users ever read sources,
X *    credits must appear in the documentation.
X *
X * 3. Altered versions must be plainly marked as such, and must not be
X *    misrepresented as being the original software.  Since few users
X *    ever read sources, credits must appear in the documentation.
X *
X * 4. This notice may not be removed or altered.
X */
END_OF_xcpustate/COPYRIGHT
if test 915 -ne `wc -c <xcpustate/COPYRIGHT`; then
    echo shar: \"xcpustate/COPYRIGHT\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f xcpustate/Imakefile -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"xcpustate/Imakefile\"
else
echo shar: Extracting \"xcpustate/Imakefile\" \(275 characters\)
sed "s/^X//" >xcpustate/Imakefile <<'END_OF_xcpustate/Imakefile'
XLOCAL_LIBRARIES = $(XAWLIB) $(XMULIB) $(XTOOLLIB) $(XLIB)
X       DEPLIBS = $(DEPXAWLIB) $(DEPXMULIB) $(DEPXTOOLLIB) $(DEPXLIB)
X           SRCS = xcpustate.c Bar.c s.c
X           OBJS = xcpustate.o Bar.o s.o
X   INSTPGMFLAGS = $(INSTKMEMFLAGS)
X
XComplexProgramTarget(xcpustate)
END_OF_xcpustate/Imakefile
if test 275 -ne `wc -c <xcpustate/Imakefile`; then
    echo shar: \"xcpustate/Imakefile\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f xcpustate/Makefile -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"xcpustate/Makefile\"
else
echo shar: Extracting \"xcpustate/Makefile\" \(9040 characters\)
sed "s/^X//" >xcpustate/Makefile <<'END_OF_xcpustate/Makefile'
X# Makefile generated by imake - do not edit!
X# $XConsortium: imake.c,v 1.51 89/12/12 12:37:30 jim Exp $
X#
X# The cpp used on this machine replaces all newlines and multiple tabs and
X# spaces in a macro expansion with a single space.  Imake tries to compensate
X# for this, but is not always successful.
X#
X
X###########################################################################
X# Makefile generated from "Imake.tmpl" and <Imakefile>
X# $XConsortium: Imake.tmpl,v 1.77 89/12/18 17:01:37 jim Exp $
X#
X# Platform-specific parameters may be set in the appropriate .cf
X# configuration files.  Site-wide parameters may be set in the file
X# site.def.  Full rebuilds are recommended if any parameters are changed.
X#
X# If your C preprocessor doesn't define any unique symbols, you'll need
X# to set BOOTSTRAPCFLAGS when rebuilding imake (usually when doing
X# "make Makefile", "make Makefiles", or "make World").
X#
X# If you absolutely can't get imake to work, you'll need to set the
X# variables at the top of each Makefile as well as the dependencies at the
X# bottom (makedepend will do this automatically).
X#
X
X###########################################################################
X# platform-specific configuration parameters - edit sun.cf to change
X
X# platform:  $XConsortium: sun.cf,v 1.38 89/12/23 16:10:10 jim Exp $
X# operating system:  SunOS 4.0.3
X
X###########################################################################
X# site-specific configuration parameters - edit site.def to change
X
X# site:  $XConsortium: site.def,v 1.21 89/12/06 11:46:50 jim Exp $
X
X            SHELL = /bin/sh
X
X              TOP = .
X      CURRENT_DIR = .
X
X               AR = ar cq
X  BOOTSTRAPCFLAGS =
X               CC = cc
X
X         COMPRESS = compress
X              CPP = /lib/cpp $(STD_CPP_DEFINES)
X    PREPROCESSCMD = cc -E $(STD_CPP_DEFINES)
X          INSTALL = install
X               LD = ld
X             LINT = lint
X      LINTLIBFLAG = -C
X         LINTOPTS = -axz
X               LN = ln -s
X             MAKE = make
X               MV = mv
X               CP = cp
X           RANLIB = ranlib
X  RANLIBINSTFLAGS =
X               RM = rm -f
X     STD_INCLUDES =
X  STD_CPP_DEFINES =
X      STD_DEFINES =
X EXTRA_LOAD_FLAGS =
X  EXTRA_LIBRARIES =
X             TAGS = ctags
X
X    SHAREDCODEDEF = -DSHAREDCODE
X         SHLIBDEF = -DSUNSHLIB
X
X    PROTO_DEFINES =
X
X     INSTPGMFLAGS =
X
X     INSTBINFLAGS = -m 0755
X     INSTUIDFLAGS = -m 4755
X     INSTLIBFLAGS = -m 0664
X     INSTINCFLAGS = -m 0444
X     INSTMANFLAGS = -m 0444
X     INSTDATFLAGS = -m 0444
X    INSTKMEMFLAGS = -m 4755
X
X          DESTDIR =
X
X     TOP_INCLUDES = -I$(INCROOT)
X
X      CDEBUGFLAGS = -O
X        CCOPTIONS =
X      COMPATFLAGS = -DXAW_BC
X
X      ALLINCLUDES = $(STD_INCLUDES) $(TOP_INCLUDES) $(INCLUDES) $(EXTRA_INCLUDES)
X       ALLDEFINES = $(ALLINCLUDES) $(STD_DEFINES) $(PROTO_DEFINES) $(DEFINES) $(COMPATFLAGS)
X           CFLAGS = $(CDEBUGFLAGS) $(CCOPTIONS) $(ALLDEFINES)
X        LINTFLAGS = $(LINTOPTS) -DLINT $(ALLDEFINES)
X           LDLIBS = $(SYS_LIBRARIES) $(EXTRA_LIBRARIES)
X        LDOPTIONS = $(CDEBUGFLAGS) $(CCOPTIONS)
X   LDCOMBINEFLAGS = -X -r
X
X        MACROFILE = sun.cf
X           RM_CMD = $(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a .emacs_* tags TAGS make.log MakeOut
X
X    IMAKE_DEFINES =
X
X         IRULESRC = $(CONFIGDIR)
X        IMAKE_CMD = $(IMAKE) -DUseInstalled -I$(IRULESRC) $(IMAKE_DEFINES)
X
X     ICONFIGFILES = $(IRULESRC)/Imake.tmpl $(IRULESRC)/Imake.rules \
X			$(IRULESRC)/Project.tmpl $(IRULESRC)/site.def \
X			$(IRULESRC)/$(MACROFILE) $(EXTRA_ICONFIGFILES)
X
X###########################################################################
X# X Window System Build Parameters
X# $XConsortium: Project.tmpl,v 1.63 89/12/18 16:46:44 jim Exp $
X
X###########################################################################
X# X Window System make variables; this need to be coordinated with rules
X# $XConsortium: Project.tmpl,v 1.63 89/12/18 16:46:44 jim Exp $
X
X          PATHSEP = /
X        USRLIBDIR = $(DESTDIR)/local/lib/X11R4
X           BINDIR = $(DESTDIR)/local/bin/X11R4
X          INCROOT = $(DESTDIR)/local/share/X11R4/include
X     BUILDINCROOT = $(TOP)
X      BUILDINCDIR = $(BUILDINCROOT)/X11
X      BUILDINCTOP = ..
X           INCDIR = $(INCROOT)/X11
X           ADMDIR = $(DESTDIR)/usr/adm
X           LIBDIR = $(DESTDIR)/local/share/X11R4
X        CONFIGDIR = $(LIBDIR)/config
X       LINTLIBDIR = $(USRLIBDIR)/lint
X
X          FONTDIR = $(LIBDIR)/fonts
X         XINITDIR = $(LIBDIR)/xinit
X           XDMDIR = $(LIBDIR)/xdm
X           AWMDIR = $(LIBDIR)/awm
X           TWMDIR = $(LIBDIR)/twm
X           GWMDIR = $(LIBDIR)/gwm
X          MANPATH = $(DESTDIR)/local/share/X11R4/man
X    MANSOURCEPATH = $(MANPATH)/man
X           MANDIR = $(MANSOURCEPATH)x
X        LIBMANDIR = $(MANSOURCEPATH)3
X      XAPPLOADDIR = $(LIBDIR)/app-defaults
X
X        SOXLIBREV = 4.2
X          SOXTREV = 4.0
X         SOXAWREV = 4.0
X        SOOLDXREV = 4.0
X         SOXMUREV = 4.0
X        SOXEXTREV = 4.0
X
X       FONTCFLAGS = -t
X
X     INSTAPPFLAGS = $(INSTDATFLAGS)
X
X            IMAKE = imake
X           DEPEND = makedepend
X              RGB = rgb
X            FONTC = bdftosnf
X        MKFONTDIR = mkfontdir
X        MKDIRHIER = /bin/sh $(BINDIR)/mkdirhier.sh
X
X        CONFIGSRC = $(TOP)/config
X        CLIENTSRC = $(TOP)/clients
X          DEMOSRC = $(TOP)/demos
X           LIBSRC = $(TOP)/lib
X          FONTSRC = $(TOP)/fonts
X       INCLUDESRC = $(TOP)/X11
X        SERVERSRC = $(TOP)/server
X          UTILSRC = $(TOP)/util
X        SCRIPTSRC = $(UTILSRC)/scripts
X       EXAMPLESRC = $(TOP)/examples
X       CONTRIBSRC = $(TOP)/../contrib
X           DOCSRC = $(TOP)/doc
X           RGBSRC = $(TOP)/rgb
X        DEPENDSRC = $(UTILSRC)/makedepend
X         IMAKESRC = $(CONFIGSRC)
X         XAUTHSRC = $(LIBSRC)/Xau
X          XLIBSRC = $(LIBSRC)/X
X           XMUSRC = $(LIBSRC)/Xmu
X       TOOLKITSRC = $(LIBSRC)/Xt
X       AWIDGETSRC = $(LIBSRC)/Xaw
X       OLDXLIBSRC = $(LIBSRC)/oldX
X      XDMCPLIBSRC = $(LIBSRC)/Xdmcp
X      BDFTOSNFSRC = $(FONTSRC)/bdftosnf
X     MKFONTDIRSRC = $(FONTSRC)/mkfontdir
X     EXTENSIONSRC = $(TOP)/extensions
X
X  DEPEXTENSIONLIB = $(USRLIBDIR)/libXext.a
X     EXTENSIONLIB =  -L$(USRLIBDIR) -lXext
X
X          DEPXLIB = $(DEPEXTENSIONLIB)
X             XLIB = $(EXTENSIONLIB) -L$(USRLIBDIR) -lX11
X
X      DEPXAUTHLIB = $(USRLIBDIR)/libXau.a
X         XAUTHLIB =  -L$(USRLIBDIR) -lXau
X
X        DEPXMULIB =
X           XMULIB = -L$(USRLIBDIR) -lXmu
X
X       DEPOLDXLIB =
X          OLDXLIB = -L$(USRLIBDIR) -loldX
X
X      DEPXTOOLLIB =
X         XTOOLLIB = -L$(USRLIBDIR) -lXt
X
X        DEPXAWLIB =
X           XAWLIB = -L$(USRLIBDIR) -lXaw
X
X LINTEXTENSIONLIB = $(USRLIBDIR)/llib-lXext.ln
X         LINTXLIB = $(USRLIBDIR)/llib-lX11.ln
X          LINTXMU = $(USRLIBDIR)/llib-lXmu.ln
X        LINTXTOOL = $(USRLIBDIR)/llib-lXt.ln
X          LINTXAW = $(USRLIBDIR)/llib-lXaw.ln
X
X        XWLIBSRC = $(CONTRIBSRC)/toolkits/Xw
X        DEPXWLIB = $(USRLIBDIR)/libXw.a
X        XWLIB =  -L$(USRLIBDIR) -lXw
X
X          DEPLIBS = $(DEPXAWLIB) $(DEPXMULIB) $(DEPXTOOLLIB) $(DEPXLIB)
X
X         DEPLIBS1 = $(DEPLIBS)
X         DEPLIBS2 = $(DEPLIBS)
X         DEPLIBS3 = $(DEPLIBS)
X
X###########################################################################
X# Imake rules for building libraries, programs, scripts, and data files
X# rules:  $XConsortium: Imake.rules,v 1.67 89/12/18 17:14:15 jim Exp $
X
X###########################################################################
X# start of Imakefile
X
XLOCAL_LIBRARIES = $(XAWLIB) $(XMULIB) $(XTOOLLIB) $(XLIB)
X       DEPLIBS = $(DEPXAWLIB) $(DEPXMULIB) $(DEPXTOOLLIB) $(DEPXLIB)
X           SRCS = xcpustate.c Bar.c s.c
X           OBJS = xcpustate.o Bar.o s.o
X   INSTPGMFLAGS = $(INSTKMEMFLAGS)
X
X PROGRAM = xcpustate
X
Xall:: xcpustate
X
Xxcpustate: $(OBJS) $(DEPLIBS)
X	$(RM) $@
X	$(CC) -o $@ $(OBJS) $(LDOPTIONS) $(LOCAL_LIBRARIES) $(LDLIBS) $(EXTRA_LOAD_FLAGS)
X
Xinstall:: xcpustate
X	$(INSTALL) -c $(INSTPGMFLAGS)   xcpustate $(BINDIR)
X
Xinstall.man:: xcpustate.man
X	$(INSTALL) -c $(INSTMANFLAGS) xcpustate.man $(MANDIR)/xcpustate.x
X
Xdepend::
X	$(DEPEND) -s "# DO NOT DELETE" -- $(ALLDEFINES) -- $(SRCS)
X
Xlint:
X	$(LINT) $(LINTFLAGS) $(SRCS) $(LINTLIBS)
Xlint1:
X	$(LINT) $(LINTFLAGS) $(FILE) $(LINTLIBS)
X
Xclean::
X	$(RM) $(PROGRAM)
X
X###########################################################################
X# common rules for all Makefiles - do not edit
X
Xemptyrule::
X
Xclean::
X	$(RM_CMD) \#*
X
XMakefile::
X	-@if [ -f Makefile ]; then \
X	echo "	$(RM) Makefile.bak; $(MV) Makefile Makefile.bak"; \
X	$(RM) Makefile.bak; $(MV) Makefile Makefile.bak; \
X	else exit 0; fi
X	$(IMAKE_CMD) -DTOPDIR=$(TOP) -DCURDIR=$(CURRENT_DIR)
X
Xtags::
X	$(TAGS) -w *.[ch]
X	$(TAGS) -xw *.[ch] > TAGS
X
X###########################################################################
X# empty rules for directories that do not have SUBDIRS - do not edit
X
Xinstall::
X	@echo "install in $(CURRENT_DIR) done"
X
Xinstall.man::
X	@echo "install.man in $(CURRENT_DIR) done"
X
XMakefiles::
X
Xincludes::
X
X###########################################################################
X# dependencies generated by makedepend
X
END_OF_xcpustate/Makefile
if test 9040 -ne `wc -c <xcpustate/Makefile`; then
    echo shar: \"xcpustate/Makefile\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f xcpustate/README -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"xcpustate/README\"
else
echo shar: Extracting \"xcpustate/README\" \(246 characters\)
sed "s/^X//" >xcpustate/README <<'END_OF_xcpustate/README'
XA snapshot performance monitor. Originally written to watch the load
Xdistribution on the CPU's on an Silicon Graphics Iris4d/240, it can be
Xadapted to display a large variety of changing system statistics.
X
X	- moraes@cs.toronto.edu (Mark Moraes)
END_OF_xcpustate/README
if test 246 -ne `wc -c <xcpustate/README`; then
    echo shar: \"xcpustate/README\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f xcpustate/patchlevel.h -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"xcpustate/patchlevel.h\"
else
echo shar: Extracting \"xcpustate/patchlevel.h\" \(21 characters\)
sed "s/^X//" >xcpustate/patchlevel.h <<'END_OF_xcpustate/patchlevel.h'
X#define PATCHLEVEL 2
END_OF_xcpustate/patchlevel.h
if test 21 -ne `wc -c <xcpustate/patchlevel.h`; then
    echo shar: \"xcpustate/patchlevel.h\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f xcpustate/s-bsd.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"xcpustate/s-bsd.c\"
else
echo shar: Extracting \"xcpustate/s-bsd.c\" \(2534 characters\)
sed "s/^X//" >xcpustate/s-bsd.c <<'END_OF_xcpustate/s-bsd.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/* Chris Siebenmann, CSRI, University of Toronto <cks@white.toronto.edu> */
X/* LINTLIBRARY */
X#include <sys/param.h>
X#include <sys/dk.h>
X#include <nlist.h>
X
X#ifndef MAXHOSTNAMELEN
X  /* Some U*x deviants managed to not have this in sys/param.h */
X# define MAXHOSTNAMELEN 64
X#endif
X
Xextern char *xmalloc(/* int nbytes */);
X
Xextern int open(), read();
Xextern long lseek();
X
Xlong	cp_time[CPUSTATES];
Xlong	cp_old[CPUSTATES];
Xint	kmem;			/* file descriptor of /dev/kmem. */
Xstruct nlist	nl[] = {
X#define	X_CP_TIME	0
X	{ "_cp_time" },
X	{ "" },
X};
X
X#define NPROCS 1
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    static char hname[MAXHOSTNAMELEN];
X
X    name[0] = hname;
X    if (gethostname(name[0], MAXHOSTNAMELEN) < 0) {
X	perror("gethostname");
X	*name[0] = '\0';
X    }
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;
X	extern void draw_bar(/*int bar_num, int *states, int num_states*/);
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[(cpustate)] - cp_old[(cpustate)]))
X
X	nstates = 0;
X	states[nstates++] = delta(CP_IDLE);
X	states[nstates++] = delta(CP_USER);
X	states[nstates++] = delta(CP_NICE);
X	states[nstates++] = delta(CP_SYS);
X	draw_bar(0, states, nstates);
X	for (i = 0; i < CPUSTATES; i ++)
X		cp_old[i] = cp_time[i];
X}
END_OF_xcpustate/s-bsd.c
if test 2534 -ne `wc -c <xcpustate/s-bsd.c`; then
    echo shar: \"xcpustate/s-bsd.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f xcpustate/s-cray-xmp.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"xcpustate/s-cray-xmp.c\"
else
echo shar: Extracting \"xcpustate/s-cray-xmp.c\" \(2716 characters\)
sed "s/^X//" >xcpustate/s-cray-xmp.c <<'END_OF_xcpustate/s-cray-xmp.c'
X/* System dependent file for Cray X/MP and Y/MP Unicos >= 5.1 Systems */
X/* Walter D. Poxon, CRI, Mendota Heights, MN  <wdp@cray.com> */
X
X#include <nlist.h>
X#include <sys/types.h>
X#include <sys/fcntl.h>
X#include <sys/unistd.h>
X#include <sys/pws.h>
X#include <errno.h>
X
X#define UNICOS "/unicos"
X#define KMEM "/dev/kmem"
X
X#define NSTATES 6
X
Xstatic struct nlist nl[] = { {"cpuw"},{0} };
Xint kmem;
Xlong bytes;
Xstruct pw cpuw;
X
Xextern char *xmalloc(/* int nbytes */);
X
Xunion cpu_name {
X  word wval;
X  struct {
X    uint : 32,
X    c    : 8,
X    p    : 8,
X    u    : 8,
X    no   : 8;
X  } cval;
X};
X
X/* Called at the beginning to inquire how many bars are needed. */
Xint
X  num_bars()
X{
X  bzero(&cpuw,sizeof(cpuw));
X
X  if (nlist(UNICOS,nl) == -1) {
X    perror("nlist");
X    return 0;
X  }
X
X  bytes = nl[0].n_value;
X
X  if ((kmem = open(KMEM, O_RDONLY)) <0) {
X    perror("open");
X    return 0;
X  }
X
X  if (lseek(kmem, bytes, SEEK_SET) != bytes)
X    perror("lseek");
X
X  if (read(kmem, &cpuw, sizeof(cpuw)) != sizeof(cpuw))
X    perror("read");
X
X  return cpuw.pw_ccpu;       /* Number of CPU's configured in UNICOS */
X/*return cpuw.pw_scpu;       /* Number of CPU's started */
X
X}
X
X
Xchar **
X  label_bars(nbars)          /* Called after num_bars to ask for bar names */
X{
X  char **names;
X  int i;
X  extern char *strcpy(/* char *, const char * */);
X  union cpu_name c;
X
X  names = (char **) xmalloc(nbars * sizeof(char *));
X  for(i = 0; i < nbars; i++) {
X    char buf[8];
X    c.wval = cpuw.pws[i].pw_cpu;
X    (void) sprintf(buf, "%c%c%c%c", c.cval.c,c.cval.p,c.cval.u,c.cval.no);
X    names[i] = strcpy(xmalloc(strlen(buf)+1), buf);
X  }
X  return names;
X}
X
X/* 
X *  Called after the bars are created to perform any machine dependent
X *  initializations.
X */
Xvoid
X  init_bars(nbars)
Xint nbars;
X{
X  (void) display_bars(nbars);
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
X#define delta(cpustate) \
X  ((int) (si[i]->cpu[(cpustate)] - last_si[i]->cpu[(cpustate)]))
X
X  display_bars(nbars)
X{
X    int states[NSTATES];
X    int nstates;
X    int cpu;
X    extern void draw_bar(/*int bar_num, int *states, int num_states*/);
X
X    if (lseek(kmem, bytes, SEEK_SET) != bytes)
X      perror("lseek");
X    
X    if (read(kmem, &cpuw, sizeof(cpuw)) != sizeof(cpuw))
X      perror("read");
X
X    for (cpu=0; cpu < nbars; cpu++) {
X      nstates = 0;
X      states[nstates++] = cpuw.pws[cpu].pw_syswe + cpuw.pws[cpu].pw_idlee;
X      states[nstates++] = cpuw.pws[cpu].pw_usere;
X      states[nstates++] = cpuw.pws[cpu].pw_unixe;
X      draw_bar(cpu, states, nstates);
X    }
X}
END_OF_xcpustate/s-cray-xmp.c
if test 2716 -ne `wc -c <xcpustate/s-cray-xmp.c`; then
    echo shar: \"xcpustate/s-cray-xmp.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f xcpustate/s-iris4d.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"xcpustate/s-iris4d.c\"
else
echo shar: Extracting \"xcpustate/s-iris4d.c\" \(3109 characters\)
sed "s/^X//" >xcpustate/s-iris4d.c <<'END_OF_xcpustate/s-iris4d.c'
X/* System dependent file for Silicon Graphics Iris4d systems */
X/* Mark Moraes, ANT, University of Toronto <moraes@cs.toronto.edu> */
X/* LINTLIBRARY */
X#include <stdio.h>
X#include <sys/types.h>
X#include <sys/sysmp.h>
X#include <sys/sysinfo.h>
X
Xextern int sysmp(/* int opcode, opcode_specific_args */);
Xextern char *xmalloc(/* int nbytes */);
X
Xstatic int *errs;
Xstatic struct sysinfo **si;
Xstatic struct sysinfo **last_si;
Xstatic struct sysinfo **tmp_si;
X
X/* Called at the beginning to inquire how many bars are needed. */
Xint
Xnum_bars()
X{
X    return sysmp(MP_NPROCS);
X}
X
X
X/* Called after num_bars to ask for the bar names */
X/* ARGSUSED */
Xchar **
Xlabel_bars(nbars)
X{
X    char **names;
X    int i;
X    extern char *strcpy(/* char *, const char * */);
X
X    names = (char **) xmalloc(nbars * sizeof(char *));
X    for(i = 0; i < nbars; i++) {
X#define CPUNAME	"%d"
X	char buf[sizeof(CPUNAME) + 32];
X
X	(void) sprintf(buf, CPUNAME, i);
X	names[i] = strcpy(xmalloc(strlen(buf) + 1), buf);
X    }
X    return names;
X}
X
X/* 
X *  Called after the bars are created to perform any machine dependent
X *  initializations.
X */
Xvoid
Xinit_bars(nbars)
Xint nbars;
X{
X    int i;
X    int ret;
X    
X    /* Initialize sysinfo by taking first reading */
X
X    last_si = (struct sysinfo **) xmalloc(nbars * sizeof(struct sysinfo *));
X    si = (struct sysinfo **) xmalloc(nbars * sizeof(struct sysinfo *));
X    errs = (int *) xmalloc(nbars * sizeof(int));
X
X    for(i = 0; i < nbars; i++) {
X	last_si[i] = (struct sysinfo *) xmalloc(sizeof(struct sysinfo));
X	si[i] = (struct sysinfo *) xmalloc(sizeof(struct sysinfo));
X	errs[i] = 0;
X	ret = sysmp(MP_SAGET1, MPSA_SINFO, (int) last_si[i],
X		    sizeof(struct sysinfo), i);
X	if (ret != 0) {
X	    (void) fprintf(stderr,
X	     "sysmp(MP_SAGET1, MPSA_SINFO) returned %d on processor %d\n",
X	     ret, i);
X	    (void) fflush(stderr);
X	    errs[i]++;
X	    continue;
X	}
X    }
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    struct sysinfo dummy;
X    int states[sizeof(dummy.cpu)/sizeof(time_t)];
X    int nstates;
X    int ret;
X    int i;
X    extern void draw_bar(/*int bar_num, int *states, int num_states*/);
X
X    for(i = 0; i < nbars; i++) {
X	if (errs[i] != 0)
X	    continue;
X	ret = sysmp(MP_SAGET1, MPSA_SINFO, (int) si[i],
X		    sizeof(struct sysinfo), i);
X	if (ret != 0) {
X	    (void) fprintf(stderr,
X	     "sysmp(MP_SAGET1, MPSA_SINFO) returned %d on processor %d\n",
X	      ret, i);
X	    (void) fflush(stderr);
X	    errs[i]++;
X	    continue;
X	}
X	    
X#define delta(cpustate) \
X((int) (si[i]->cpu[(cpustate)] - last_si[i]->cpu[(cpustate)]))
X
X	nstates = 0;
X	states[nstates++] = delta(CPU_IDLE) + delta(CPU_WAIT);
X	states[nstates++] = delta(CPU_USER);
X	states[nstates++] = delta(CPU_KERNEL);
X	states[nstates++] = delta(CPU_SXBRK);
X	states[nstates++] = delta(CPU_INTR);
X	draw_bar(i, states, nstates);
X    }
X    tmp_si = last_si;
X    last_si = si;
X    si = tmp_si;
X}
END_OF_xcpustate/s-iris4d.c
if test 3109 -ne `wc -c <xcpustate/s-iris4d.c`; then
    echo shar: \"xcpustate/s-iris4d.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f xcpustate/s.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"xcpustate/s.c\"
else
echo shar: Extracting \"xcpustate/s.c\" \(464 characters\)
sed "s/^X//" >xcpustate/s.c <<'END_OF_xcpustate/s.c'
X/*
X * for each type of machine, stick the appropriate ifdef's in here and define
X * s_included.  If s_included is not defined, it assumes BSD (i.e look for
X * _cp_time in kmem)
X */
X#ifdef sgi
X# ifdef mips
X#  include "s-iris4d.c"
X#  define s_included
X# endif
X#endif
X
X#ifdef CRAY1
X# include "s-cray-xmp.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"
X#endif
X/* Do not add anything after this line */
END_OF_xcpustate/s.c
if test 464 -ne `wc -c <xcpustate/s.c`; then
    echo shar: \"xcpustate/s.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f xcpustate/s.h -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"xcpustate/s.h\"
else
echo shar: Extracting \"xcpustate/s.h\" \(262 characters\)
sed "s/^X//" >xcpustate/s.h <<'END_OF_xcpustate/s.h'
X/*
X *  Any system dependent file must implement these routines. See s-bsd.c
X *  and s-iris4d.c for examples.
X */
Xextern int num_bars();
Xextern char **label_bars(/* int nbars */);
Xextern void init_bars(/* int nbars */);
Xextern void display_bars(/* int nbars */);
END_OF_xcpustate/s.h
if test 262 -ne `wc -c <xcpustate/s.h`; then
    echo shar: \"xcpustate/s.h\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f xcpustate/xcpustate.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"xcpustate/xcpustate.c\"
else
echo shar: Extracting \"xcpustate/xcpustate.c\" \(5546 characters\)
sed "s/^X//" >xcpustate/xcpustate.c <<'END_OF_xcpustate/xcpustate.c'
X/*
X*  Displays CPU state distribution
X*/
X#ifndef lint
Xstatic char rcsid[] = "$Header: /ai/lambda/X.V11R4/contrib/clients/xcpustate/RCS/xcpustate.c,v 1.2 90/02/20 00:33:36 xwindows Exp $";
X#endif /*lint*/
X
X#include <stdio.h>
X
X#include <X11/Xos.h>
X#include <X11/StringDefs.h>
X#include <X11/Intrinsic.h>
X#include <X11/Xaw/Form.h>
X#include <X11/Xaw/Label.h>
X#include <X11/Xmu/Xmu.h>
X#include "Bar.h"
X#include "s.h"
X
X#define MAXSTR 512
X#define DEF_INTERVAL	1
X#define DEF_COUNT		-1
X
Xchar *progname;
Xstatic int defaultInterval = DEF_INTERVAL;
Xstatic int defaultCount = DEF_COUNT;
Xstatic int count, interval;
X
X/* Application Resources - no particular widget */
Xstatic XtResource application_resources[] = {
X    {"interval", "Interval", XtRInt, sizeof(int),
X	    (Cardinal)&interval, XtRInt, (caddr_t) &defaultInterval},
X    {"count", "Count", XtRInt, sizeof(int),
X	    (Cardinal)&count, XtRInt, (caddr_t) &defaultCount},
X};
X
X/*
X*  Command line options table. The command line is parsed for these,
X*  and it sets/overrides the appropriate values in the resource
X*  database
X*/
Xstatic XrmOptionDescRec optionDescList[] = {
X    {"-interval",   ".interval",    XrmoptionSepArg,    (caddr_t) NULL},
X    {"-count",	    ".count",	    XrmoptionSepArg,    (caddr_t) NULL},
X};
X
X/*
X*  DON'T CHANGE THE ORDER OF THE ARGS IN THE VARIOUS ARG STRUCTS. IF
X*  YOU WANT TO ADD STUFF, ADD IT AT THE END OF THE STRUCT, BECAUSE WE
X*  REFER TO SOME OF THE ELEMENTS BY POSITION IN THE CODE.
X*/
X/* No spacing between the widgets on the Form */
Xstatic Arg form_args[] = {
X    {XtNdefaultDistance, (XtArgVal) 0},
X};
X
Xstatic Arg subform_args[] = {
X    {XtNfromVert, (XtArgVal) 0},
X    {XtNdefaultDistance, (XtArgVal) 0},
X    {XtNborderWidth, (XtArgVal) 0},
X    {XtNtop, (XtArgVal) XtChainTop},
X    {XtNbottom, (XtArgVal) XtChainTop}, /* ChainBottom causes strange resize */
X    {XtNright, (XtArgVal) XtChainRight},
X    {XtNleft, (XtArgVal) XtChainLeft},
X};
X
Xstatic Arg bar_args[] = {
X    {XtNfromHoriz, (XtArgVal) 0},
X    {XtNorientation, (XtArgVal) XtorientHorizontal},
X    {XtNborderWidth, (XtArgVal) 1},
X    {XtNlength, (XtArgVal) ((Dimension) 200)},
X    {XtNthickness, (XtArgVal) ((Dimension) 20)},
X    {XtNtop, (XtArgVal) XtChainTop},
X    {XtNbottom, (XtArgVal) XtChainTop},
X    {XtNright, (XtArgVal) XtChainRight},
X    {XtNleft, (XtArgVal) XtChainLeft},
X    {XtNvertDistance, (XtArgVal) 0},
X    {XtNhorizDistance, (XtArgVal) 0},
X    {XtNresizable, (XtArgVal) TRUE},
X};
X
Xstatic Arg label_args[] = {
X    {XtNlabel, (XtArgVal) 0},
X    {XtNjustify, (XtArgVal) XtJustifyLeft},
X    {XtNborderWidth, (XtArgVal) 0},
X    {XtNtop, (XtArgVal) XtChainTop},
X    {XtNbottom, (XtArgVal) XtChainTop},
X    {XtNright, (XtArgVal) XtChainLeft},
X    {XtNleft, (XtArgVal) XtChainLeft},
X    {XtNvertDistance, (XtArgVal) 0},
X    {XtNhorizDistance, (XtArgVal) 0},
X    {XtNresizable, (XtArgVal) FALSE},
X};
X
Xvoid
Xusage()
X{
X    (void) fprintf(stderr, "\
XUsage: %s [Xt options] [-count iterations] [-interval delay_seconds\n",
X     progname);
X    exit(-1);
X}
X
Xchar *
Xxmalloc(n)
Xint n;
X{
X    extern char *malloc();
X    char *cp = malloc((unsigned) n);
X    if (cp == NULL) {
X	    (void) fprintf(stderr, "Couldn't malloc %d bytes\n", n);
X	    exit(-1);
X    }
X    return cp;
X}
X
Xstatic int nbars;
Xstatic Widget *bar;
Xstatic char **barnames;
X    
Xmain(argc, argv)
Xint argc;
Xchar **argv;
X{
X    int i;
X    static XtTimerCallbackProc update_display();
X    Widget topLevel;
X    Widget form, label;
X	Widget subform = NULL;
X    extern char *strchr(/* const char *, char */);
X
X    if ((progname = strchr(argv[0], '/')) == NULL)
X	progname = argv[0];
X    else
X	progname++;
X
X    nbars = num_bars();
X    if (nbars == 0) {
X	(void) fprintf(stderr, "num_bars returned 0 - something is wrong\n");
X	exit(-1);
X    }
X    bar = (Widget *) xmalloc(nbars * sizeof(Widget));
X    barnames = label_bars(nbars);
X
X    topLevel = XtInitialize(progname, "CPUStateMonitor",
X			    optionDescList, XtNumber(optionDescList),
X			    &argc, argv);
X
X    if (argc > 1)
X	usage();
X	
X    XtGetApplicationResources(topLevel, 0, application_resources,
X			      XtNumber(application_resources), NULL, 0 );
X
X    form = XtCreateManagedWidget("form", formWidgetClass, topLevel,
X				 form_args, XtNumber(form_args));
X    
X    for(i = 0; i < nbars; i++) {
X#define FORMNAMEFMT	"form%d"
X	char formname[sizeof(FORMNAMEFMT) + 32];
X#define BARNAMEFMT	"bar%d"
X	char barname[sizeof(BARNAMEFMT) + 32];
X
X	if (i > 0)
X	    subform_args[0].value = (XtArgVal) subform;
X	(void) sprintf(formname, FORMNAMEFMT, i);
X	subform = XtCreateManagedWidget(formname, formWidgetClass, form,
X				 subform_args, XtNumber(subform_args));
X	label_args[0].value = (XtArgVal) barnames[i];
X	label = XtCreateManagedWidget(barnames[i], labelWidgetClass, subform,
X				      label_args, XtNumber(label_args));
X	(void) sprintf(barname, BARNAMEFMT, i);
X	bar_args[0].value = (XtArgVal) label;
X	bar[i] = XtCreateManagedWidget(barname, barWidgetClass, subform,
X				    bar_args, XtNumber(bar_args));
X    }
X    XtRealizeWidget(topLevel);
X
X    init_bars(nbars);
X    
X    (void) XtAddTimeOut((unsigned long) (interval * 1000), update_display,
X			(caddr_t) NULL);
X    XtMainLoop();
X}
X
X/* ARGSUSED */
Xstatic XtTimerCallbackProc
Xupdate_display(closure, id)
Xcaddr_t closure;
XXtIntervalId *id;
X{
X    display_bars(nbars);
X    
X    if (count > 0) {
X	if (--count == 0)
X	    return;
X    }
X    (void) XtAddTimeOut((unsigned long) (interval * 1000), update_display,
X			(caddr_t) NULL);
X}
X
Xvoid
Xdraw_bar(i, states, nstates)
Xint i;
Xint states[];
Xint nstates;
X{
X    SetBarValues((Widget) bar[i], states, nstates);
X}
END_OF_xcpustate/xcpustate.c
if test 5546 -ne `wc -c <xcpustate/xcpustate.c`; then
    echo shar: \"xcpustate/xcpustate.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f xcpustate/xcpustate.man -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"xcpustate/xcpustate.man\"
else
echo shar: Extracting \"xcpustate/xcpustate.man\" \(2420 characters\)
sed "s/^X//" >xcpustate/xcpustate.man <<'END_OF_xcpustate/xcpustate.man'
X.TH XCPUSTATE 1 "13 July 1988" "X Version 11"
X.SH NAME
Xxcpustate - display CPU states (idle, nice, system, kernel) statistics
X.SH SYNTAX
X\fBxcpustate\fP [\fI-toolkitoption\fP ...] [\fI-count\fP iterations] 
X[\fI-interval\fP seconds]
X.SH DESCRIPTION
X.I Xcpustate
Xdisplays bars showing the percentage of time the CPU spends in
Xdifferent states. 
X.PP
XOn a machine running Berkeley Unix, or a derivative (Suns with SunOS,
XmicroVaxen with Ultrix), the bar indicates the proportions of idle,
Xuser, nice, and system time with increasing levels of gray scale (from
Xleft to right) 
X.PP
XOn an Iris4D, there may be more than one bar, one for each CPU, and
Xeach bar indicates the proportions of idle + wait, user, kernel, sxbrk
Xand interrupt time for each cpu.
X.PP
XOn a Cray X/MP or Y/MP, under Unicos 5.1 or greater, it will display
Xbars for as many cpus as are configured.  The proportions of
Xidle, user and system time are shown for each cpu.
X.SH OPTIONS
X.I Xcpustate
Xaccepts all of the standard X Toolkit command line options, plus:
X.TP 8
X.IR -count " iterations"
XThe number of times it should update the display. Default is forever.
X.TP 8
X.IR -interval " seconds"
Xthe interval in between updates. Default is 1 second.
X.SH X DEFAULTS
XFor
X.I xcpustate
Xthe available class identifiers are:
X.sp
X.nf
XCPUStateMonitor - the application
XForm - enclosing the entire application, and sub-Forms enclosing 
XLabel/Bar pairs.
X.fi
X.PP
XFor
X.I xcpustate,
Xthe available name identifiers are:
X.sp
X.nf
Xxcpustate - application name
XThe outer Form is "form".
XThe Forms enclosing the Label/Bar pairs are "formN", where N is the
Xindex number, starting with the top pair as zero.
XEach Label name is the same as the label string.
XEach Bar name is "barN".
X.fi
X.sp
X.LP
XFor
X.I xcpustate,
Xthe available resources are:
X.IP "name interval, class Interval"
Xcorresponds to the -interval option. Takes an integer value.
X.IP "name count, class Count"
Xcorresponds to the -count argument, also takes and integer value.
X.SH NOTES
X.I Xcpustate 
Xwas designed for a multiprocessor (a Silicon Graphics Iris4D/240) - it
Xhappens to work for conventional BSD uniprocessors. It is meant to be
Xeasy to port, and extend to monitor a wide variety of statistics.
X.SH SEE ALSO
Xxperfmon, xload
X.SH AUTHOR
XMark Moraes, University of Toronto
XThanks to Chris Siebenmann for the code for BSD systems.
XThanks to Walter D. Poxon from Cray Research for the code for Cray X/MP and
XY/MPs.
END_OF_xcpustate/xcpustate.man
if test 2420 -ne `wc -c <xcpustate/xcpustate.man`; then
    echo shar: \"xcpustate/xcpustate.man\" unpacked with wrong size!
fi
# end of overwriting check
fi
echo shar: End of shell archive.
exit 0

dan
-----------------------------------------------------------
		    O'Reilly && Associates
		argv@sun.com / argv@ora.com
	   632 Petaluma Ave, Sebastopol, CA 95472 
     800-338-NUTS, in CA: 800-533-NUTS, FAX 707-829-0104
    Opinions expressed reflect those of the author only.