Google
 

Trailing-Edge - PDP-10 Archives - bb-d868b-bm_tops20_v3a_2020_dist - 3a-sources/watch.mac
There are 22 other files named watch.mac in the archive. Click here to see a list.
;<3A.UTILITIES>WATCH.MAC.4, 31-May-78 15:18:48, EDIT BY BOSACK
;<3A.UTILITIES>WATCH.MAC.2, 27-Feb-78 14:31:11, Edit by BORCHEK
;make append output work again
;<3-UTILITIES>WATCH.MAC.6,  8-Nov-77 10:51:33, EDIT BY KIRSCHEN
;MORE COPYRIGHT UPDATING...
;<3-UTILITIES>WATCH.MAC.5, 26-Oct-77 11:21:45, EDIT BY KIRSCHEN
;UPDATE COPYRIGHT FOR RELEASE 3
;<3-UTILITIES>WATCH.MAC.4, 11-Jul-77 17:28:31, EDIT BY MURPHY
;ADD/CHANGE AJBL, DSKR, DSKW, SWPR, UPGS, FPGS
;SNARK:<3-UTILITIES>WATCH.MAC.2,  2-May-77 14:15:18, EDIT BY CURRIER
;TCO #1789 - CHECK FOR ENUFF TABLE SPACE
;<2-UTILITIES>WATCH.MAC.17, 20-Jan-77 14:18:01, EDIT BY HURLEY
;FIX HELP MESSAGE
;<2-UTILITIES>WATCH.MAC.16, 27-Dec-76 17:08:19, EDIT BY HURLEY
;<2-UTILITIES>WATCH.MAC.15,  3-Nov-76 11:44:36, EDIT BY MURPHY
;<2-UTILITIES>WATCH.MAC.13, 11-Oct-76 14:48:19, EDIT BY MURPHY
;<2-UTILITIES>WATCH.MAC.8, 11-Oct-76 08:52:15, EDIT BY HURLEY
;<2-UTILITIES>WATCH.MAC.7,  7-Oct-76 17:58:24, EDIT BY MURPHY
;<2-UTILITIES>WATCH.MAC.2, 29-Sep-76 21:30:17, EDIT BY HURLEY
;MAKE WATCH RUN UNDER RELEASE 2
;<2-UTILITIES>WATCH.MAC.1, 26-Jul-76 17:08:32, EDIT BY MURPHY
;<MURPHY>WATCH.MAC.7, 26-Jul-76 12:09:42, EDIT BY MURPHY
;<MURPHY>WATCH.MAC.6, 23-Jul-76 18:46:37, EDIT BY MURPHY
;<MURPHY>WATCH.MAC.4, 23-Jul-76 18:41:10, EDIT BY MURPHY
;TCO #1476 - JOB SUMMARY AND MONITOR STATISTICS QUESTIONS; ETC.
;<MURPHY>WATCH.MAC.3, 23-Jul-76 16:09:46, EDIT BY MURPHY
;<MURPHY>WATCH.MAC.2, 23-Jul-76 15:34:42, EDIT BY MURPHY
;TCO #1475 - ADDITIONAL INFORMATION; 24 HOUR BUG; BETTER EXPLANATIONS
;<1A-UTILITIES>WATCH.MAC.6,  6-MAY-76 11:04:15, EDIT BY HURLEY
;<1A-UTILITIES>WATCH.MAC.3,  8-APR-76 11:53:54, EDIT BY HURLEY
;TCO 1244 - ADD .DIRECT .XTABM FOR MACRO 50 ASSEMBLIES
;<1A-UTILITIES>WATCH.MAC.2, 31-MAR-76 09:48:04, EDIT BY HURLEY
;TCO # 1227 - ADD TOPS-20 ENTRY VECTOR AND VERSION NUMBER
;<MACK>WATCH.MAC.3, 23-FEB-76 09:15:34, Edit by MACK
;REVISED ABBREVIATION LIST -- AAM.
;<UTILITIES-MACK>WATCH.MAC.5, 11-JAN-76 16:25:04, EDIT BY LEWINE
; NEW WATCH/SWATCH HYBRID --- 01 AUG 75 --- AA. MACK



;THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY ONLY BE USED
;  OR COPIED IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE.
;
;COPYRIGHT (C) 1976, 1977, 1978 BY DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.

	TITLE WATCH

	SEARCH MACSYM,MONSYM
	.REQUIRE SYS:MACREL
	SALL
   IFDEF .PSECT,<		;IF MACRO 51 OR BETTER,
	.DIRECT FLBLST>		;MAKE BETTER LISTING
   IFNDEF .PSECT,<
	.DIRECT .XTABM>
	MLON

; VERSION NUMBER DEFINITIONS

VMAJOR==3			;MAJOR VERSION OF WATCH
VMINOR==1			;MINOR VERSION NUMBER
VEDIT==7			;EDIT NUMBER
VWHO==0				;GROUP WHO LAST EDITED PROGRAM (0=DEC DEVELOPMENT)

VWATCH== <VWHO>B2+<VMAJOR>B11+<VMINOR>B17+VEDIT
;ACCUMULATORS

F=0				;FLAGS
A=1
 T1=A
B=2
 T2=B
C=3
 T3=C
D=4

E=5
FF=6				; DITTO
G=7				; DITTO

P1=10
P2=11

P=17

NMIN==^D<15*60>			; NO. OF SECONDS IF UNDER JOB 0

FLDSIZ==12
JBMAX==^D200			;SIZE OF JOB TABLES

;FLAGS IN F

JOBSMF==1B0			;PRINT JOB SUMMARY
STATF==1B1			;PRINT MONITOR STATISTICS SUMMARY
NOTIMF==1B2			;NO TIME PERIOD GIVEN
;PROGRAM ENTRY VECTOR

ENTVEC:	JRST WATCH		;STARTING LOCATION
	JRST WATCH		;REENTER LOCATION
	VWATCH			;VERSION NUMBER

WATCH:	RESET
	MOVE P,[IOWD PDLEN,PDL]
	SETZ F,
	MOVE A,[SIXBIT/JOBRT/]
	SYSGT
	HLRE A,B
	MOVNM A,NJOBS
	CAMGE A,[-JBMAX]	; ENUFF ROOM?
	 JRST [HRROI A,[ASCIZ/
? NOT ENOUGH ROOM IN JOB TABLES!
/]
	       PSOUT
	       HALTF]
	GJINF
	JUMPE C,[MOVSI A,1
		HRROI B,[ASCIZ/<SYSTEM>WATCH.LOG/]
		GTJFN
		 JRST [	MOVSI A,400001
			HRROI B,[ASCIZ/PS:<SYSTEM>WATCH.LOG/]
			GTJFN
			 JRST [HRROI A,[ASCIZ/
? WATCH NOT BEING PERFORMED!
/]
				PSOUT
				HALTF
				JRST WATCH]
			JRST .+1]
		MOVEM A,OJFN
		MOVE B,[70000,,120000]
		OPENF
		 JRST [HRROI A,[ASCIZ/
? WATCH NOT BEING PERFORMED!
/]
			PSOUT
			HALTF
			JRST WATCH]
		TXO F,JOBSMF+STATF ;DO ALL OUTPUT
		MOVE B,[NMIN]	;USE DEFAULT TIME PERIOD
		JRST GOTTIM]
	TMSG <
WATCH >
	MOVEI A,.PRIOU
	MOVE B,[VWATCH]		;PRINT WATCH VERSION
	CALL PVERID
	TMSG <, /H for help.
>
GOJFN:	TMSG <Output to file: >
	PBIN			;CHECK FIRST CHAR
	CAIN A,"?"
	JRST [	TMSG < Output filespec for WATCH output.
>
		JRST GOJFN]
	CAIN A,"/"		;SWITCH?
	JRST [	CALL RDLINE	;YES, GET NAME
		LDB A,[POINT 7,STRING,6] ;GET FIRST CHAR OF SWITCH
		CAIN A,"H"	;HELP?
		JRST DOHLP	;YES, TYPE LONG MESSAGE
		TMSG <?Invalid switch.
>
		JRST GOJFN]
	MOVEI A,.PRIIN
	BKJFN			;PUT IT BACK
	 JFCL
	MOVX A,GJ%MSG+GJ%CFM+GJ%FNS+GJ%SHT
	MOVE B,[100,,101]
	GTJFN
	 JRST [	CALL ERMSG
		JRST WATCH]
	MOVEM A,OJFN
	MOVE B,[70000,,120000]
	OPENF
	 JRST [	CALL ERMSG
		MOVE A,OJFN
		RLJFN
		 JFCL
		JRST WATCH]
	TMSG <Print monitor statistics? >
	CALL YESNO		;GET ANSWER
	SKIPE A
	TXO F,STATF		;YES
	TMSG <Print job summary ? >
	PSOUT
	CALL YESNO		;GET ANSWER
	SKIPE A
	TXO F,JOBSMF		;YES
	; ..
TIMLOP:	HRROI A,[ASCIZ/
Time period (MM:SS): /]
	PSOUT
	CALL RDLINE		;READ TO CR
	LDB A,[POINT 7,STRING,6] ;GET FIRST CHAR
	CAIN A,"?"		;HELP REQUEST?
	JRST [	HRROI A,[ASCIZ /
For fixed period reporting, enter the period as MM:SS.  Type CR
for variable period reporting.  This means that a report will
be done only when requested by typing CR.
/]
		PSOUT		;TYPE HELP
		JRST TIMLOP]	;TRY AGAIN
	CAIN A,.CHLFD		;ONLY CR TYPED?
	JRST [	TXO F,NOTIMF	;YES, FLAG
		HRROI A,[ASCIZ /
Type CR to get report.
/]
		PSOUT
		SETZ B,		;TIME IS 0
		JRST GOTTIM]
	CAIN A,":"		;STARTS WITH COLON?
	JRST [	SETZM WAITIM	;YES, ASSUME SECONDS FOLLOW
		MOVE A,[POINT 7,STRING,6]
		JRST TIMLO1]
	HRROI A,STRING
	FLIN			;SEE IF INPUT CAN BE RECOGNIZED AS
	 JRST BADTIM		; FLOATING PT - JUMP IF NOT
	LDB C,A			;OK, BUT MUST HAVE READ ENTIRE FIELD
	CAIE C," "
	CAIN C,.CHLFD
	JRST [	FMPRI B,(60.0)	;OK, CONVERT TO SECONDS
		FIXR B,B	;FIX
		JRST GOTTIM]
	CAIN C,":"		;COLON TERMINATOR?
	JRST TIMLO2		;YES, SECONDS GIVEN
BADTIM:	TMSG <?Invalid time period specification.
>
	JRST TIMLOP		;TRY AGAIN

TIMLO2:	FIXR B,B		;FIX MINUTES
	IMULI B,^D60		;CONVERT TO SECONDS
	MOVEM B,WAITIM
TIMLO1:	MOVEI C,^D10
	NIN			;YES, GET NUMBER
	 PUSHJ P,LJSHLT
	ADD B,WAITIM		;ADD TO MINUTES
	; ..
;HERE WITH: B/ TIME PERIOD IN SECONDS

	; ..
GOTTIM:	IMULI B,^D1000		;CONVERT TO MILLISECONDS
	MOVEM B,WAITIM
	TMSG <
WATCH IN OPERATION -- >
	MOVEI A,377777
	EXCH A,OJFN
	PUSH P,A
	TIME
	MOVEM A,STIME
	SETZM INTRVL
	PUSHJ P,SETUP
	JRST INTERR
	PUSHJ P,GETQS		;INIT QUEUE TIMES
	PUSHJ P,GSTATS		;INIT STATISTICS TABLES
	PUSHJ P,CALPER
	PUSHJ P,HEADER
	PUSHJ P,SORT
	PUSHJ P,TYPE
	POP P,OJFN
	JRST LPWAIT
;MAIN LOOP

LOOP:	TIME
	SUBM A,STIME		;COMPUTE ACTUAL INTERVAL
	EXCH A,STIME		;SAVE CURRENT TIME
	MOVEM A,INTRVL
	PUSHJ P,SETUP
	JRST INTERR
	PUSHJ P,GETQS		;GET QUEUE TIMES
	PUSHJ P,GSTATS		;GET STATISTICS
	PUSHJ P,CALPER
	PUSHJ P,HEADER
	PUSHJ P,SORT
	TXNE F,JOBSMF		;SKIP IF JOB SUMMARY NOT WANTED
	PUSHJ P,TYPE
	MOVE A,OJFN
	HRLI A,(1B0)
	CLOSF
	  JFCL
	HRRZ A,OJFN
	MOVE B,[70000,,120000]
	OPENF
	  JRST [MOVE B,A
		HRROI A,[ASCIZ/
? CANNOT REOPEN OUTPUT FILE!
? /]
		PSOUT
		MOVEI A,101
		SETZ C,
		HRLI B,400000
		ERSTR
		  JFCL
		  JFCL
		HALTF
		JRST WATCH]
LPWAIT:	JXO F,NOTIMF,[PBIN	;INDEF PERIOD, GET TYPEIN
		CAIE A,.CHLFD	;CR TYPED?
		JRST LPWAIT	;NO, KEEP WAITING
		JRST LOOP]	;YES, DO REPORT
	TIME
	SUB A,STIME
	MOVNS A
	ADD A,WAITIM
	SKIPL A
	DISMS
	JRST LOOP
;TYPE JOB SUMMARY

TYPE:	PUSH P,P1
	PUSH P,P2
	PUSHJ P,CRLF
	HRROI A,[ASCIZ/JOB/]
	MOVEI B,4
	PUSHJ P,TYPSTR
	HRROI A,[ASCIZ/TTY/]
	MOVEI B,4
	PUSHJ P,TYPSTR
	HRROI A,[ASCIZ/PROGRAM/]
	MOVEI B,10
	PUSHJ P,TYPSTR
	HRROI A,[ASCIZ/RUN TIME/]
	MOVEI B,12
	PUSHJ P,TYPSTR
	HRROI A,[ASCIZ/DELTA RT/]
	MOVEI B,12
	PUSHJ P,TYPSTR
	HRROI A,[ASCIZ/  %/]
	MOVEI B,10
	PUSHJ P,TYPSTR
	HRROI A,[ASCIZ/USER/]
	MOVEI B,10
	PUSHJ P,TYPSTR
	PUSHJ P,CRLF
	PUSHJ P,CRLF
	MOVN P1,NJOBS
	HRLZS P1
TYPLOP:	MOVE P2,JOBNUM(P1)
	SKIPN USER(P2)
	  JRST TYPNXT
	SKIPG DRUNTM(P2)
	  JRST TYPNXT
	MOVE A,P2
	MOVEI B,4
	PUSHJ P,TYPDEC
	SKIPGE A,TTYNUM(P2)
	  JRST [MOVE A,[ASCII/DET/]
		MOVEM A,STRING
		MOVEI B,4
		PUSHJ P,TYPFLD
		JRST TYPE2]
	MOVEI B,4
	PUSHJ P,TYPOCT
TYPE2:	MOVE A,PRGNAM(P2)
	MOVEI B,10
	PUSHJ P,TYPSIX
	MOVE A,RUNTIM(P2)
	MOVEI B,12
	PUSHJ P,TYPRT
	FLTR A,DRUNTM(P2)
	FDVR A,[1000.0]
	MOVEI B,12
	PUSHJ P,TYPFLT
	MOVE A,PERCNT(P1)
	MOVEI B,10
	PUSHJ P,TYPPER
	MOVE A,USER(P2)
	MOVEI B,6
	PUSHJ P,TYPUSR
	PUSHJ P,CRLF
TYPNXT:	AOBJN P1,TYPLOP
	POP P,P2
	POP P,P1
	POPJ P,

TYPSTR:	PUSH P,B
	MOVE B,A
	HRROI A,STRING
	SETZ C,
	SOUT
	POP P,A
	JRST TYPFLD

TYPRT:	PUSH P,B
	IDIVI A,^D1000
	IDIVI A,^D60		; B = SECONDS, A = MINUTES
	PUSH P,B
	IDIVI A,^D60		; B = MINUTES, A = HOURS
	PUSH P,B
	MOVE B,A
	HRROI A,STRING		;WRITE TIME TO BUFFER STRING
	MOVX C,<NO%LFL+NO%AST+FLD(3,NO%COL)+^D10>
	NOUT
	 JFCL
	MOVEI B,":"
	BOUT
	POP P,B			;RECOVER MINUTES
	MOVX C,<NO%LFL+NO%ZRO+FLD(2,NO%COL)+^D10>
	NOUT			;PRINT MINUES
	 JFCL
	MOVEI B,":"
	BOUT
	POP P,B			;RECOVER SECONDS
	NOUT			;PRINT SECONDS
	 JFCL
	POP P,A
	JRST TYPFLD
TYPDEC:	SKIPA C,[12]
TYPOCT:	MOVEI C,10
	PUSH P,B
	MOVE B,A
	HRROI A,STRING
	NOUT
	  SETZM STRING
	POP P,A
	JRST TYPFLD

TYPPER:	PUSH P,B
	MOVE B,A
	HRROI A,STRING
	MOVE C,[1B4!1B6!37B17!2B23!2B29]
	FLOUT
	  JRST TYPZER
	MOVEI B,"%"
	IDPB B,A
	PUSHJ P,SPACE		; SPACE OVER
	MOVEI B,0
	IDPB B,A
	POP P,A
	JRST TYPFLD

TYPUSR:	PUSH P,B
	MOVE B,A
	HRROI A,STRING
	DIRST
TYPZER:	SETZM STRING
	POP P,A
	JRST TYPFLD

TYPSIX:	PUSH P,B
	PUSHJ P,SIXTO7
	POP P,A
	JRST TYPFLD

SIXTO7:	MOVE B,[POINT 7,STRING]
	MOVE C,[POINT 6,A]
	MOVEI D,6
	ILDB E,C
	ADDI E,40
	IDPB E,B
	SOJG D,.-3
	MOVEI E,0
	IDPB E,B
	POPJ P,
TYPFLD:	MOVE D,[POINT 7,STRING]
	MOVE E,A
	MOVE A,OJFN
TYPFL1:	ILDB B,D
	JUMPE B,TYPFL2
	BOUT
	SOJA E,TYPFL1
TYPFL2:	PUSHJ P,SPACE		; SPACE OVER
	SOJG E,TYPFL2
	POPJ P,
;
; CRLF -- TURNS A NEW LINE
;
CRLF:	HRROI B,[ASCIZ/
/]
	MOVE A,OJFN
	SETZ C,
	SOUT
	POPJ P,

; JSYS ERROR ROUTINE

ERMSG:	TMSG <
? >
	JRST ERMSG0

LJSERR:	TMSG <
?JSYS ERROR: >
ERMSG0:	MOVEI A,101		; SET UP OUTJFN
	HRLOI B,.FHSLF
	SETZ C,			;
	ERSTR			; PRINT ERROR MESSAGE
	 JFCL			;
	 JFCL			; IGNORE ALL SCREWUP CONDITIONS
	HRROI A,[ASCIZ/
/]
	PSOUT			;
	POPJ P,			;

LJSHLT:	PUSHJ P,LJSERR		;DO MESSAGE
	HALTF			;QUIT
	POPJ P,			;BUT IF CONTINUED...

INTERR:	TMSG <
? WATCH: FATAL INTERNAL ERROR!
>
	HALTF
	JRST WATCH
;READ YES/NO ANSWER

YESNO:	CALL RDLINE		;READ TYPEIN TO NEXT CR
	LDB B,[POINT 7,STRING,6] ;GET FIRST CHAR OF ANSWER
	CAIN B,"?"		;HELP?
	JRST [	HRROI A,[ASCIZ /
"YES" OR "NO": /]
		PSOUT
		JRST YESNO]	;TRY AGAIN
	CAIE B,"Y"
	CAIN B,"Y"+40
	JRST [	SETO A,		;YES, RETURN NON-0
		RET]
	CAIE B,"N"
	CAIN B,"N"+40
	JRST [	SETZ A,		;NO, RETURN 0
		RET]
	HRROI A,[ASCIZ /? YES OR NO REQUIRED: /]
	PSOUT
	JRST YESNO

;READ ONE LINE FROM PRIMARY

RDLINE:	PBIN			;READ FIRST CHAR
	CAIN A,"?"		;HELP REQUEST?
	JRST [	SETZM STRING	;YES, RETURN IMMEDIATELY
		DPB A,[POINT 7,STRING,6]
		RET]
	MOVEI A,.PRIIN
	BKJFN			;NO, PUT IT BACK
	 CALL LJSERR
	MOVE A,[.PRIIN,,.PRIOU]
	HRROI B,STRING
	MOVX C,<RD%BEL+RD%JFN+RD%RAI+RD%CRF+STRNGL*5-1>
	RDTXT
	 CALL LJSHLT
	RET
;PRINT VERSION IDENTIFICATION
; A/ OUTPUT DESIGNATOR
; B/ VERSION ID WORD

PVERID:	SAVEAC <P1>
	MOVEM T2,P1		;SAVE WORD
	MOVEI T3,^D8		;ALL NUMBERS ARE OCTAL
	LOAD T2,VI%MAJ,P1	;MAJOR VERSION
	NOUT
	 JFCL
	LOAD T2,VI%MIN,P1	;MINOR
	JUMPE T2,PVER1		;PRINT NOTHING IF 0
	ADDI T2,"A"-1		;CONVERT TO ALPHABETIC
	BOUT
PVER1:	MOVEI T2,"("
	BOUT			;PUNCTUATE EDIT NUMBER
	LOAD T2,VI%EDN,P1
	NOUT
	 JFCL
	MOVEI T2,")"
	BOUT
	LOAD T2,VI%WHO,P1	;GET CUSTOMER CODE
	JUMPE T2,PVER2		;JUMP IF NONE
	MOVEI T2,"-"		;PUNCTUATE IT
	BOUT
	LOAD T2,VI%WHO,P1
	NOUT
	 JFCL
PVER2:	RET
;
; HEADER CODE BEGINS HERE
;
HEADER:	MOVE A,OJFN
	HRROI B,[ASCIZ/


WATCH SUMMARY AT /]
	SETZ C,
	SOUT
	MOVNI B,1
	SETZ C,
	ODTIM
	HRROI B,[ASCIZ/
	FOR AN INTERVAL OF /]
	SETZ C,
	SOUT
	MOVE A,INTRVL
	MOVEI B,0
	PUSHJ P,TYPRT
	MOVE A,OJFN
	HRROI B,[ASCIZ/ WITH /]
	SETZ C,
	SOUT
	PUSHJ P,SUMJOB
	MOVEI B,3
	PUSHJ P,TYPDEC
	MOVE A,OJFN
	HRROI B,[ASCIZ/ ACTIVE JOBS.
/]
	SETZ C,
	SOUT
	JXE F,STATF,SKSTAT	;JUMP IF NOT PRINTING STATISTICS
	PUSHJ P,STATS
	PUSHJ P,PQSUM		;PRINT QUEUE TIME SUMMARY
SKSTAT:	MOVE A,OJFN
	HRROI B,[ASCIZ /
LOAD AVERAGES:       /]
	SETZ C,
	SOUT
	MOVE A,[SIXBIT/SYSTAT/]
	SYSGT
	PUSH P,B
	MOVE A,0(P)
	HRLI A,14
	GETAB
	  JFCL
	MOVEI B,10
	PUSHJ P,TYPFLT
	MOVE A,0(P)
	HRLI A,15
	GETAB
	  JFCL
	MOVEI B,10
	PUSHJ P,TYPFLT
	POP P,A
	HRLI A,16
	GETAB
	  JFCL
	MOVEI B,10
	PUSHJ P,TYPFLT
	PUSHJ P,CRLF
	HRROI A,[ASCIZ /HIGH QUEUE AVERAGES: /]
	MOVEI B,.HQLAV
	PUSHJ P,DOLAV
	HRROI A,[ASCIZ /LOW QUEUE AVERAGES:  /]
	MOVEI B,.LQLAV
	PUSHJ P,DOLAV
	POPJ P,

;TYPE LOAD AVERAGES
; A/ MESSAGE
; B/ TABLE TO BE USED

DOLAV:	SAVEAC <P1>
	ASUBR <MSG,TABLE>
	HRRO A,TABLE		;REQUEST SIZE OF TABLE
	GETAB
	 RET			;NONE SUCH, DO NOTHING
	HRLZ P1,A		;SETUP AOBJN PTR
	MOVE A,OJFN
	SETZ C,
	HRRO B,MSG
	SOUT			;TYPE MESSAGE
DOLAV1:	MOVE A,TABLE
	HRL A,P1		;SETUP INDEX,,TABLE
	GETAB			;GET ENTRY
	 PUSHJ P,LJSHLT		;IMPOSSIBLE
	MOVEI B,10		;FIELD SIZE
	PUSHJ P,TYPFLT		;TYPE IT
	AOBJN P1,DOLAV1		;DO ALL
	PUSHJ P,CRLF		;END OF LINE
	RET

TYPFLT:	PUSH P,B
	MOVE B,A
	HRROI A,STRING
	MOVE C,[1B1!1B4!1B6!37B17!4B23!2B29] ;4 COLUMNS
	FLOUT
	  JRST TYPZER
	POP P,A
	JRST TYPFLD
SETUP:	PUSH P,P1
	MOVN P1,NJOBS
	HRLZS P1
SETLOP:	HRRZ A,P1
	MOVE B,[-10,,JIBLK]
	MOVEI C,0
	GETJI
	  JRST SETZER		;
	SKIPN A,JIBLK+.JIUNO
	  JRST SETZER
	MOVEM A,USER(P1)
	MOVE A,JIBLK+.JIJNO
	MOVEM A,JOBNUM(P1)
	MOVE A,JIBLK+.JITNO
	MOVEM A,TTYNUM(P1)
	MOVE A,JIBLK+.JIPNM
	MOVEM A,PRGNAM(P1)
	MOVE A,JIBLK+.JIRT
	SUB A,RUNTIM(P1)
	SKIPGE A
	  SETZ A,
	MOVEM A,DRUNTM(P1)
	MOVE A,JIBLK+.JIRT
	MOVEM A,RUNTIM(P1)
SETNXT:	AOBJN P1,SETLOP
	POP P,P1
CPOPJ1:	AOS (P)
CPOPJ:	POPJ P,

SETZER:	SETZM PERCNT(P1)
	SETZM USER(P1)
	SETZM RUNTIM(P1)
	SETZM DRUNTM(P1)
	SETOM JOBNUM(P1)
	SETOM TTYNUM(P1)
	JRST SETNXT
SUMJOB:	MOVN B,NJOBS
	HRLZS B
	SETZ A,
SUMJLP:	SKIPE USER(B)
	  AOS A
	AOBJN B,SUMJLP
	POPJ P,

CALPER:	PUSH P,P1
	FLTR A,INTRVL
	PUSH P,A
	MOVN P1,NJOBS
	HRLZS P1
CALLOP:	FLTR A,DRUNTM(P1)
	FDVR A,0(P)
	FMPR A,[100.0]
	MOVEM A,PERCNT(P1)
	AOBJN P1,CALLOP
	POP P,(P)
	POP P,P1
	POPJ P,

SORT:	PUSH P,P1
SORT1:	MOVN P1,NJOBS
	HRLZS P1
	SETZ D,
SORTLP:	MOVE A,PERCNT(P1)
	CAML A,PERCNT+1(P1)
	  JRST SORNXT
	EXCH A,PERCNT+1(P1)
	MOVEM A,PERCNT(P1)
	MOVE A,JOBNUM(P1)
	EXCH A,JOBNUM+1(P1)
	MOVEM A,JOBNUM(P1)
	SETO D,
SORNXT:	AOBJN P1,SORTLP
	JUMPN D,SORT1
	POP P,P1
	POPJ P,
;
; HERE BEGINS CODE FOR STAT GATHERING
;  --- AA. MACK
;
GSTATS:	MOVE A,[SIXBIT /SYSTAT/] ; GET SYSTEM TABLE
	SYSGT			;
	JUMPE B,[HRROI A,[ASCIZ/SYSTAT TABLE NOT FOUND
/]
		PSOUT
		HALTF]
	HRRZM B,SYSTAT		; SAVE TABLE NUMBER
	HLRE A,B		; NEGATIVE OF LENGTH
	MOVMM A,NSYST		;
	HLLM B,NSYST		; NSYST/-LENGTH,,+LENGTH
	MOVE A,[SIXBIT/JOBRT/]	; GET JOBRT TABLE
	SYSGT			;
	JUMPE B,[HRROI A,[ASCIZ/JOBRT TABLE NOT FOUND
/]
		PSOUT
		HALTF]
	HRRZM B,JOBRT		;
	HLRE A,B		;
	MOVMM A,NNJOBS		; SAME AS FOR SYSTAT
	HLLM B,NNJOBS		;
	MOVE A,[SIXBIT /XBIO/]	;TRY TO GET XB IO TABLE
	SYSGT			; ...
	HRRZM B,XBIO		;SAVE
	HLLZ E,NNJOBS		;
GTA1:	HRRZ A,JOBRT		; JOB RUNTIME TABLE
	HRLI A,0(E)		; 
	GETAB			;
	JRST [	PUSHJ P,LJSERR
		SETZ A,		; USE 0 IF FAILURE
		JRST .+1]
	MOVEM A,JNEW(E)		;
	AOBJN E,GTA1		; LOOP TO GET ALL
	HLLZ E,NSYST		; SYSTAT TABLE
GTA2:	HRRZ A,SYSTAT		;
	HRLI A,0(E)		;
	GETAB			;
	JRST [	PUSHJ P,LJSERR
		SETZ A,
		JRST .+1]
	MOVEM A,VNEW(E)		;
	AOBJN E,GTA2		; LOOP TO GET ALL 
	SKIPG A,XBIO		;GET XBIO INDEX
	JRST GTA3		;NONEX
	HRLI A,0		;FIRST GET READS
	GETAB
	 JRST GTA3
	MOVEM A,XBRNEW		;SAVE
	MOVE A,XBIO		;GET WRITES
	HRLI A,1		; ...
	GETAB
	 JRST GTA3
	MOVEM A,XBWNEW		;SAVE WRITES
GTA3:	TIME			; GET CURRENT TIME
	MOVEM A,TNEW		; SAVE IT
	POPJ P,			;
;PRINT STATISTICS

STATS:	MOVE A,TNEW		; COMPUTE SAMPLE INTERVAL
	SUBM A,TOLD		;
	PUSHJ P,CRLF		; TURN A NEW LINE
	MOVSI G,-NVALS		; SET UP TO DO ALL VALUES
	MOVNI FF,4		; 4 STATISTICS PER LINE
GO1:	HLRZ A,VNAMES(G)	; POINTER TO CALL WORD
	MOVE E,0(A)		; CALL WORD, IE. INDEX,,ROUTINE
	HLRZ A,E		; A/0,,INDEX
	PUSHJ P,0(E)		; PERFORM SPECIFIED FUNCTION
	AOBJN G,GO1		; LOOP TO DO WHOLE TABLE
	PUSHJ P,CRLF		; NEW LINE
	MOVE A,[XWD VNEW,VOLD]	; MAKE CURRENT SET BE OLD SET
	BLT A,TOLD		;   FOR NEXT TIME THRU LOOP
	POPJ P,			; BACK TO "HEADER" CODE
; DOPCT -- ITEM AS PERCENTAGE OF REALTIME INTERVAL
;
DOPCT:	MOVE B,VNEW(A)		;
	SUBB B,VOLD(A)		;
	MOVE A,B		;
DOPCT1:	IMULI A,1750		; 1750 = 1000
DOPCT3: IDIV A,TOLD		; GET PERCENT*10
	ASH B,1			; ROUNDING -- IF REMAINDER IS
	CAML B,TOLD		;  GEQ DIVISOR/2, THEN ADD 1
	ADDI A,1		;
DOPCT2:	IDIVI A,12		; SPLIT INTO INTEGER & FRACTION
	CAIL A,144		; GREATER THAN 100% ?
	JRST [	PUSHJ P,LABEL	; YES, JUST PRINT INTEGER
		MOVE B,A
		MOVE A,OJFN
		MOVE C,[1B2+1B4+1B5+4B17+12] ; 4 COLUMNS
		NOUT
		JFCL
		MOVEI B,"."
		BOUT
		PUSHJ P,SPACE	;
		PUSHJ P,SPACE	; SPACE FOR COLUMNS
		PUSHJ P,SPACE	;
		JUMPE FF,[ PUSHJ P,CRLF
			   MOVNI FF,4
			   POPJ P, ]
		POPJ P,  ]
	PUSH P,B		; SAVE FRACTION
	PUSHJ P,LABEL		; PRINT STAT NAME
	MOVE B,A		; 
	MOVE A,OJFN		;
	MOVE C,[1B2+1B4+1B5+3B17+12] ; 3 COLUMNS FOR INTEGER
	NOUT			; PRINT THE NUMBER
	JFCL			;
	MOVEI B,"."		;
	BOUT			;
	POP P,B			;
	HRLI C,(1B4+1B5+1B17)	; ONE COLUMN FOR FRACTION
	NOUT			; PRINT THE FRACTION
	JFCL			;
	PUSHJ P,SPACE		;
	PUSHJ P,SPACE		;
	PUSHJ P,SPACE		;
	JUMPE FF,[ PUSHJ P,CRLF
		   MOVNI FF,4
		   POPJ P, ]
	POPJ P,			; AND GO BACK
; FUNCTIONS TO COMPUTE SYSTAT & JOBRT DATA
;
; DOUSE -- TAKES NO INDEX, ADDS UP ALL JOB RUN TIMES
;
DOUSE:	HLLZ D,NNJOBS		; NUMBER OF JOBS ON SYSTEM
	SETZB A,JOBCT		; SET TO ACCUMULATE RUN TIMES
DOUSE2:	SKIPGE B,JNEW(D)	; IF JOB DOESN'T EXIST, SKIP IT
	JRST DOUSE1		;
	SKIPL C,JOLD(D)		; IF JOB DIDN'T EXIST BEFORE,
	CAMGE B,C		;  OR LOGGED OUT AND IN AGAIN,
	SETZ C,			;  USE 0 AS PREVIOUS RUNTIME
	SUB B,C			; NEW - OLD
	MOVEM B,JOLD(D)		; SAVE INTERVAL RUN TIME FOR JOB
	ADD A,B			; ACCUMULATE TOTAL RUN TIME
	AOS JOBCT		;
DOUSE1: AOBJN D,DOUSE2		; LOOP BACK TO DO ALL
	JRST DOPCT1		; GO DO PERCENTAGE OF INTERVAL

; LABEL -- PRINTS A STAT NAME
;
LABEL:	PUSH P,A		; STACK A
	MOVE A,OJFN		;
	HRRO B,VNAMES(G)	; OUTPUT STAT NAME
	SETZ C,			;
	SOUT			; PRINT THE LABEL
	HRROI B,[ASCIZ/: /]	;
	SETZ C,			;
	SOUT			;
	ADDI FF,1		; INCREMENT FF
	POP P,A			; RESTORE A
	POPJ P,			; AND GO BACK
; DONUM -- INTEGER NUMBER
;
DONUM:	PUSHJ P,LABEL		; PRINT A STAT NAME
	MOVE B,VNEW(A)		;
	SUBB B,VOLD(A)		;
PNUM:	MOVE A,OJFN		; SET UP FOR OUTPUT
	MOVE C,[1B2+1B4+1B5+5B17+12] ; 5 COLUMNS
	NOUT			;
	JFCL			;
	PUSHJ P,SPACE		;
	PUSHJ P,SPACE		; SPACE FOR COLUMNS
	PUSHJ P,SPACE		;
	JUMPE FF,[ PUSHJ P,CRLF
		   MOVNI FF,4
		   POPJ P, ]	; CONTINUE
	POPJ P,			; AND GO BACK

; DOAV -- AVERAGE COMPUTED FROM INTEGRAL OVER DT
;
DOAV:	MOVE B,VNEW(A)		;
	SUBB B,VOLD(A)		;
	IMULI B,12		; FOR ONE PLACE AFTER POINT
	MOVE A,B		;
	JRST DOPCT3		; GO DIVIDE BY DT

; DOAVB -- AVERAGE COMPUTED FROM INTEGRAL.DBALSETTIME
;
DOAVB:	MOVE B,VNEW(A)		;
	SUBB B,VOLD(A)		;
	IMULI B,1750		; 1750 = 1000
	IDIV B,VOLD+NBWTX	; DIVIDE BY NBWT
	ASH C,1			; ROUNDING -- SEE DOPCT3
	CAML C,VOLD+NBWTX	;
	ADDI B,1		;
	MOVE A,B		;
	JRST DOPCT2		;
;DOXB - PRINT XBIO VALUES

DOXB:	POPJ P,			;**TEMP**
	PUSHJ P,LABEL		;OUTPUT NAME
	MOVE B,XBRNEW(A)	;GET VALUE
	SUB B,XBROLD(A)		;GET DIFFERENCE
	PUSHJ P,PNUM		;PRINT IT
	POPJ P,			;DONE


; SPACE -- INSERTS A SPACE WHEN NECESSARY
;
SPACE:	MOVEI B," "		; NULL CHARACTER
	BOUT			; SPACE OVER
	POPJ P,			; RETURN
;
; LISTIT -- PRINTS LIST OF SWATCH ABBREVIATIONS TO TTY:
;           AT USER'S REQUEST
;
LISTIT:	HRROI A,HELP		; GRAB THE LIST
	PSOUT			;
	POPJ P,			; AND GO BACK
; TABLE OF ITEMS TO BE REPORTED

;ITEMS ARE PRINTED 4 ACROSS PAGE, HENCE SOME USEFUL GROUPINGS OF 4
;SHOULD BE NOTED WHEN ADDING NEW ITEMS

DEFINE VNAME(NM,SUBR,LC)<
	XWD [XWD LC,SUBR],[ASCIZ/NM/]>

VNAMES:	VNAME(USED,DOPCT,32)
	VNAME(IDLE,DOPCT,0)
	VNAME(SWPW,DOPCT,1)
	VNAME(SKED,DOPCT,2)

	VNAME(SUSE,DOUSE,0)
	VNAME(NCOR,DONUM,23)
	VNAME(AJBL,DONUM,36)
	VNAME(NREM,DONUM,25)

	VNAME(TRAP,DOPCT,3)
	VNAME(NRUN,DOAV,13)
	VNAME(NBAL,DOAV,NBALX)
	VNAME(BSWT,DOAV,NBWTX)

	VNAME(DSKR,DOAVB,17)
	VNAME(DSKW,DOAVB,35)
	VNAME(SWPR,DOAVB,20)
	VNAME(UPGS,DOAV,37)

	VNAME(DMRD,DONUM,4)
	VNAME(DMWR,DONUM,5)
	VNAME(DKRD,DONUM,6)
	VNAME(DKWR,DONUM,7)

	VNAME(TTIN,DONUM,21)
	VNAME(TTOU,DONUM,22)
	VNAME(WAKE,DONUM,10)
	VNAME(TTCC,DONUM,11)

	VNAME(FPGS,DOAV,40)
	VNAME(XBRD,DOXB,0)
	VNAME(XBWT,DOXB,1)
NVALS==.-VNAMES
NBALX==12
NBWTX==26
;HERE FOR INITIAL HELP

DOHLP:	PUSHJ P,LISTIT		; PRINT THE LIST
	JRST GOJFN

; LIST OF ABBREVIATIONS USED
;

HELP:	ASCIZ /

    ALL DATA IS FOR LAST INTERVAL ONLY.

USED: USED TIME AS PERCENTAGE
IDLE: IDLE TIME AS PERCENTAGE
SWPW: SWAP-WAIT TIME AS PERCENTAGE
SKED: SCHEDULER OVERHEAD TIME AS PERCENTAGE
SUSE: SUM OF JOB RUNTIMES AS PERCENTAGE
NCOR: NUMBER OF GCCOR'S (GARBAGE-COLLECT CORE)
AJBL: NUMBER OF FORCED CALLS TO AJBALS (ADJUST BALANCE SET)
NREM: COUNT OF FORCED PROCESS REMOVALS
TRAP: PAGER TRAP SERVICE TIME PERCENTAGE (COUNTS IN USED ALSO)
NRUN: AVERAGE NUMBER RUNNABLE FORKS DURING INTERVAL
NBAL: AVERAGE NUMBER FORKS IN BALANCE SET DURING INTERVAL
BSWT: AVERAGE NUMBER BALANCE SET FORKS WAITING DURING INTERVAL
DSKR: PERCENT OF BALANCE SET WAITS ATTRIBUTABLE TO DSK READS
DSKW: PERCENT OF BALANCE SET WAITS ATTRIBUTABLE TO DSK WRITES
SWPR: PERCENT OF BALANCE SET WAITS ATTRIBUTABLE TO SWAP READS
UPGS: AVERAGE NUMBER OF PAGES IN THE BALANCE SET (SUM OF WORKING SET SIZES)
DMRD: NUMBER OF DRUM READS
DMWR: NUMBER OF DRUM WRITES
DKRD: NUMBER OF DISK READS
DKWR: NUMBER OF DISK WRITES
TTIN: NUMBER OF TERMINAL INPUT CHARACTERS
TTOU: NUMBER OF TERMINAL OUTPUT CHARACTERS
WAKE: NUMBER OF PROCESS WAKEUPS
TTCC: NUMBER OF TERMINAL INTERRUPTS
FPGS: AVERAGE NUMBER OF FREE PAGES (PAGES ON REPLACABLE QUEUE)

QUEUE DISTRIBUTION PERCENTAGE: FRACTION OF "USED" TIME USED ON
	EACH SCHEDULER QUEUE.
LOAD AVERAGES: EXPONENTIAL AVERAGE OF NUMBER OF RUNNABLE FORKS WITH
	TIME CONSTANTS OF 1, 5, AND 15 MINUTES.
HIGH QUEUE AVERAGES: COMPONENT OF LOAD AVERAGE DUE TO FORKS ON
	INTERACTIVE QUEUES.
LOW QUEUE AVERAGES: COMPONENT OF LOAD AVERAGE DUE TO FORKS ON
	COMPUTE QUEUE.

RUN TIME: TOTAL ACCUMULATED RUN TIME OF JOB (ALL FORKS) AS HH:MM:SS.
DELTA RT: JOB RUNTIME IN LAST INTERVAL
%: JOB RUNTIME AS PERCENTAGE OF "USED"
/
;QUEUE TIMES LOGIC

;READ CURRENT QUEUE TIMES INTO TABLE

GETQS:	MOVE A,[QTTAB,,OQTTAB]
	BLT A,OQTTAB+NQTAB-1	;COPY CURRENT DATA TO OLD
	MOVE A,[SIXBIT /QTIMES/]
	SYSGT			;GET TABLE PARAMETERS
	HLLZ D,B
	HLREM B,NQUEUE		;SAVE NEG TABLE SIZE
GETQS1:	HRRZ A,B		;SETUP  INDEX,,TABLE NUMBER
	HRL A,D
	GETAB
	 JFCL
	MOVEM A,QTTAB(D)	;SAVE DATA
	AOBJN D,GETQS1
	RET

;PRINT QUEUE TIMES AS PERCENTAGE OF INTERVAL

PQSUM:	MOVE A,OJFN
	HRROI B,[ASCIZ /QUEUE DISTRIBUTION PERCENTAGE: /]
	SETZ C,
	SOUT
	HRLZ D,NQUEUE
PQSUM1:	MOVE B,QTTAB(D)		;GET CURRENT TIME
	SUB B,OQTTAB(D)		;COMPUTE DELTA
	FLTR B,B		;FLOAT IT
	FMPRI B,(100.0)		;COMPUTE PERCENTAGE
	FLTR C,INTRVL
	FDVR B,C
	MOVX C,<FLD(.FLLSP,FL%JUS)+FL%ONE+FL%PNT+FLD(4,FL%FST)+FLD(2,FL%SND)>
	FLOUT			;PRINT IT
	 JFCL
	AOBJN D,PQSUM1
	PUSHJ P,CRLF		;DO CRLF
	RET
JOBNUM:	BLOCK JBMAX
TTYNUM:	BLOCK JBMAX
USER:	BLOCK JBMAX
PRGNAM: BLOCK JBMAX
RUNTIM: BLOCK JBMAX
DRUNTM: BLOCK JBMAX
PERCNT: BLOCK JBMAX
STR:	0

NJOBS:	0
OJFN:	0
WAITIM:	0
STIME:	0
INTRVL:	0
SOLDTM:	0
NULTIM: 0
LOSTIM: 0
SCHEDT: 0
JIBLK:	BLOCK 10
	STRNGL==20
STRING: BLOCK STRNGL
	PDLEN==20
PDL:	BLOCK PDLEN

NNJOBS:	BLOCK 1
NSYST:	BLOCK 1
SYSTAT:	BLOCK 1
JOBRT:	BLOCK 1
XBIO:	BLOCK 1
JOBCT:  BLOCK 1
;
; ITEM TABLES -- ORDER OF NEW MUST BE SAME AS ORDER OF OLD:
;  V MUST BE FIRST & T MUST BE LAST
;

NSTATW==50			;NUMBER OF STATISTICS WORDS MAX
VOLD:	BLOCK NSTATW
JOLD:   BLOCK JBMAX
XBROLD:	BLOCK 1
XBWOLD:	BLOCK 1
TOLD:	BLOCK 1

VNEW:	BLOCK NSTATW
JNEW:	BLOCK JBMAX
XBRNEW:	BLOCK 1
XBWNEW:	BLOCK 1
TNEW:	BLOCK 1

NQTAB==7			;MAX NUMBER QUEUES POSSIBLE
QTTAB:	BLOCK NQTAB		;CURRENT QUEUE TIMES
OQTTAB:	BLOCK NQTAB		;PREVIOUS QUEUE TIMES
NQUEUE:	BLOCK 1			;ACTUAL NUMBER QUEUES (NEGATIVE)


	END <3,,ENTVEC>