[comp.sources.misc] v06i032: SCO Xenix 286 renice part1/2

allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc) (02/04/89)

Posting-number: Volume 6, Issue 32
Submitted-by: wht@tridom.UUCP (Warren Tucker)
Archive-name: renice.sco/part01

This renice command works nicely under SCO XENIX 286 2.2.1.

#!/bin/sh
# shar:	Shell Archiver  (v1.22)
#
#	Run the following text with /bin/sh to create:
#	  README
#	  Makefile
#	  uxlst.h
#	  libuxlst.h
#	  libkmem.h
#
if test -f README; then echo "File README exists"; else
echo "x - extracting README (Text)"
sed 's/^X//' << 'SHAR_EOF' > README &&
XWell, here is a renice for SCO XENIX V/286.
XIt is derived from the 386 renice program written by Mike "Ford" Ditto.
XI changed it in two ways:
X
X1.  The 'xlist' procedure is performed by a separate program (uxlst)
Xand the resulting xlist structure array is stored in /xenix.uxlst.
XRenice thus may obtain xlist information rapidly without xlist(3) each
Xtime it is executed.  Also stored in /xenix.uxlst is a stat structure of
X/xenix at the time of uxlst execution.  A unique word is stored at the
Xend of the file in case /xenix.uxlst's xlist structure is expanded for
Xother applications.  The renice program reads /xenix.uxlst by means
Xof facilities in libuxlst.c.  If the stat structure in /xenix.uxlst
Xdoes not match a dynamic stat of /xenix or if the unique word does
Xnot match, the xlist information is not trusted and renice prompts
Xthe user to run (or have run) the uxlst program to update /xenix.uxlst.
X
X2.  I changed the usage syntax to follow the Berkeley usage:
X          renice <nice> pid ...
Xwhere <nice> is in the range -20 to 19, inclusive.  If I had known
XI was going to post the program, I probably would have retained
X"Ford"'s syntax for conditional compilation.
X
XNOTES:
X1.  uxlst must be run by root with umask 22.  
X2.  making against Makefile as root will make
X    a. uxlst
X    b. renice
X    c. run uxlst to produce /xenix.uxlst
X3.  When renice is run by root, any process may be set to any nice
Xvalue.  When renice is run by other than root, only processes owned
Xby the user may be affected and then only to reduce the priority of
Xthe process.
X
X4.  Sources are in 4-spaced tab format (please don't flame :-).
X
XWarren Tucker N4HGF
X...!gatech!kd4nc!tridom!wht
X
SHAR_EOF
chmod 0644 README || echo "restore of README fails"
fi
if test -f Makefile; then echo "File Makefile exists"; else
echo "x - extracting Makefile (Text)"
sed 's/^X//' << 'SHAR_EOF' > Makefile &&
X#  CHK=0xC596
X#+--------------------------------------------------------------
X#  Makefile for uxlst utilities
X#  must be run by root with umask 22
X#---------------------------------------------------------------
X#+:EDITS:*/
X#:10-28-1988-14:33-wht-turn off fcrc for posting to net
X#:10-27-1988-13:07-wht-creation (uxlst, renice and /xenix.uxlst)
X
X#handle Sys V make "feature" of using SHELL
XSHELL = /bin/sh
X
XLFLAGS = -i -s -M2e 
XCFLAGS = -c -O -K -DLINT_ARGS $(LFLAGS)
X#FCRC = fcrc -u $*.c ;
X
X.c.o:;	$(FCRC) cc $(CFLAGS) $*.c 
X
XUXLST_OBJ =\
X	uxlst.o
X
XRENICE_OBJ =\
X	renice.o\
X	libkmem.o\
X	libuxlst.o
X
Xall: uxlst renice /xenix.uxlst
X
Xshar:
X	shar -v -x README Makefile uxlst.h libuxlst.h libkmem.h > renice.shar.1
X	shar -v -x libkmem.c libuxlst.c uxlst.c renice.c > renice.shar.2
X
Xuxlst: $(UXLST_OBJ)
X	cc $(LFLAGS) $(UXLST_OBJ) -o uxlst
X
Xrenice: $(RENICE_OBJ)
X	cc $(LFLAGS) $(RENICE_OBJ) -o renice
X	chmod u+s renice
X
X/xenix.uxlst: uxlst /xenix
X	uxlst
X
Xclean:
X	rm -f $(RENICE_OBJ) $(UXLST_OBJ)
X
Xclobber: clean
X	rm -f uxlst renice renice.shar.1 renice.shar.2
X
Xuxlst.o: uxlst.h
Xlibuxlst.o: uxlst.h libuxlst.h
Xlibkmem.o: libkmem.h
Xrenice.o: uxlst.h libuxlst.h libkmem.h
SHAR_EOF
chmod 0644 Makefile || echo "restore of Makefile fails"
fi
if test -f uxlst.h; then echo "File uxlst.h exists"; else
echo "x - extracting uxlst.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > uxlst.h &&
X/* CHK=0x5438 */
X/*+-------------------------------------------------------------------------
X	uxlst.h -- utility xlist - fast access to kernel /dev/kmem offsets
X
XThe uxlst file contains three records:
X1.  struct stat xstat - stat buffer from /xenix at file creation time
X2.  struct xlist uxlst - the structure of xlist'd information
X3.  long unique - a unique identifier to help ensure correct uxlst length
X
XNOTE: the xl_name pointers are INVALID in programs using /xenix.uxlst
X--------------------------------------------------------------------------*/
X/*+:EDITS:*/
X/*:10-27-1988-11:07-wht-creation */
X
X#define XENIX_KERNEL	"/xenix"
X#define XENIX_UXLST		"/xenix.uxlst"
X#define UXLST_UNIQUE	0xEFBC9A78L
X
X#define procaddr (uxlst[0].xl_value)
X#define	vaddr (uxlst[1].xl_value)
X
X#ifdef DEFINE_UXLST
Xstruct xlist	uxlst[] =
X{
X	{ 0,0,0,"_proc"},
X	{ 0,0,0,"_v"},
X	{ 0,0,0,(char *)0},
X};
X#else
Xextern struct xlist uxlst[];
X#endif
X
X/* vi: set tabstop=4 shiftwidth=4: */
SHAR_EOF
chmod 0644 uxlst.h || echo "restore of uxlst.h fails"
fi
if test -f libuxlst.h; then echo "File libuxlst.h exists"; else
echo "x - extracting libuxlst.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > libuxlst.h &&
X/* CHK=0x4BC6 */
X/*+-----------------------------------------------------------------------
X	libuxlst.h
X------------------------------------------------------------------------*/
X/*+:EDITS:*/
X/*:10-28-1988-14:47-afterlint-creation */
X
X#ifndef BUILDING_LINT_ARGS
X#ifdef LINT_ARGS
X
X/* libuxlst.c */
Xvoid uxlst_error(int );
Xvoid uxlst_read(void);
X
X#else		/* compiler doesn't know about prototyping */
X
X/* libuxlst.c */
Xvoid uxlst_error();
Xvoid uxlst_read();
X
X#endif /* LINT_ARGS */
X#endif /* BUILDING_LINT_ARGS */
X
X/* end of libuxlst.h */
SHAR_EOF
chmod 0644 libuxlst.h || echo "restore of libuxlst.h fails"
fi
if test -f libkmem.h; then echo "File libkmem.h exists"; else
echo "x - extracting libkmem.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > libkmem.h &&
X/* CHK=0x3FE9 */
X/*+-----------------------------------------------------------------------
X	libkmem.h
X------------------------------------------------------------------------*/
X/*+:EDITS:*/
X/*:10-28-1988-14:46-afterlint-creation */
X
X#ifndef BUILDING_LINT_ARGS
X#ifdef LINT_ARGS
X
X/* libkmem.c */
Xvoid kinit(int );
Xvoid kread(char  *,long ,long );
Xvoid kwrite(long ,char  *,long );
X
X#else		/* compiler doesn't know about prototyping */
X
X/* libkmem.c */
Xvoid kinit();
Xvoid kread();
Xvoid kwrite();
X
X#endif /* LINT_ARGS */
X#endif /* BUILDING_LINT_ARGS */
X
X/* end of libkmem.h */
SHAR_EOF
chmod 0644 libkmem.h || echo "restore of libkmem.h fails"
fi
exit 0
---------------------------------------------------------
W. Tucker ...!gatech!{emory,kd4nc}!tridom!wht