.Title USE .Enabl LC .Ident /X02.00/ .Nlist BEX .Nlist ME ;USE.MAC - Program to display the top CPU users on VT52 or VT100... ; ; T. Miles, 24-Sep-82 ; TRIUMF ; 4004 Wesbrook Mall ; Vancouver, B.C. ; CANADA, V6T 1W5 ; ; Modified for the PRO 350 by R Uleski, Baker Instruments ; ; Modified for MPLUS V4.1 usage by ; U.Schmeling, CSA Da.-Weiterstadt: ; ; - external task header support ; - executive vectoring ; - cursor positioning for header time field corrected ; EFN =1 ; Local Event Flag RATE =5. ; Seconds per Scan SIZE =8. ; Number of Tasks displayed TILUN =1 ; Terminal Lun ; ; Layout of Info Block ; I.UIC =.-. ; UIC of Task I.NAM =I.UIC+2 ; RAD50 Task Name I.CPU =I.NAM+4 ; CPU use (ticks) I.LEN =I.CPU+2 ; Length of Entry .library /lb:[1,1]exemc.mlb/ ; ; System Directives ; .MCALL ALTP$,DIR$,EXIT$S,GTIM$C,MRKT$C,QIOW$C,QIOW$S,WTSE$C ; ; System Definitions ; .MCALL HDRDF$,PCBDF$,TCBDF$, GIN$ ; HDRDF$ ; Define header Offsets PCBDF$ ; Define partition Offsets TCBDF$ ; Define task Offsets ; ; Macro to generate spaces ; .MACRO .PAD X .REPT X .BYTE 40 .ENDR .ENDM ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; Executive Vector ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; VECTOR: EXEVEC: .WORD 0 ISAR6:: .WORD KISAR6 ; pointer to Kernal APR 6 D Space ACTHD:: .WORD $ACTHD ; active Task listhead SYSID:: .WORD $SYSID ; System Id TKTCB:: .WORD $TKTCB SIGFL:: .word $SIGFL veclen=<<.-vector>/2> ; USE:: dir$ #getvec ;+ USC001 fill the vector bcc 4$ mov @$dsw,r0 ; if failed... bpt ;- USC001 show the world 4$: CALL INIT ; Print Mask, Initialize ; LOOP: CALL RESET ; Zero Histogram, init TIMER ; CALL TICK ; Update Histogram ; CALL SORT ; Sort Histogram ; CALL DISPLY ; Output Histogram ; BR LOOP ; ...and go again ; INIT: CALL POS11 ; Position Cursor CALL CLR ; Clear Screen to End QIOW$C IO.ATA,TILUN,,,,,AST MOV @SYSID,ID ; MOVB @SYSID,ID ; Install System I.D. ; MOVB @SYSID+1,ID+1 ; ...continue QIOW$C IO.WVB,TILUN,EFN,,,, RTS PC ; ...and return ; RESET: GTIM$C TIMBUF ; Get the Time CALL POS250 ; Position the Cursor ; ...under the title MOV #BUFFER,R0 ; R0 --> Line Buffer MOV #TIMBUF+G.TIHR,R1 MOV #3.,R2 ; Format control CALL $TIM ; ...for Convert CALL PRINT ; Print the Line ; MOV #RATE*60.,TIMER ; Reload timer MOV #IBLK,R0 ; R0 --> Info Block ; 10$: CLR I.UIC(R0) ; Clear Task UIC CLR I.NAM(R0) ; Clear Task Name CLR I.NAM+2(R0) ; ...continue CLR I.CPU(R0) ; ...and CPU ADD #I.LEN,R0 ; Point to next CMP #IBLK+,R0 BHI 10$ ; ...more to do ; MOV #250.,PRI+A.LTPR; Raise priority DIR$ #PRI ; ...to limit RTS PC ; ...and return ; TICK: MRKT$C EFN,1,1 ; Set flag in one tick WTSE$C EFN ; ...and wait for it MOV #IBLK,R0 ; R0 --> Info Block MOV @ACTHD,R1 ; R1 --> Active Table EMT 376 ; Go to System State .WORD 10$ ; ...where to continue BR 20$ ;; System State 10$: DEC TIMER ; Indicate Event BNE TICK ; ...continue if more CLR PRI+A.LTPR ; Else lower priority DIR$ #PRI ; ...to kosher level RTS PC ; ...and return ; 20$: BIT #TS.EXE!TS.CKR,T.STAT(R1) BNE 30$ ;; ...task not runnable BIT #T2.SPN!T2.STP!T2.WFR,T.ST2(R1) BNE 30$ ;; ...task is blocked CMP @SIGFL,R1 ;; ...sig. event wait BEQ 30$ ;; ...yes, not runnable CMP @TKTCB,R1 ;; ...bypass our task BNE 60$ ;; ...not our task 30$: MOV T.ACTL(R1),R1 ;; ...R1 --> Next TCB BNE 20$ ;; ...and continue ; MOV #NULL-T.NAM,R1 ;; Hack for V4.0 BR 60$ ;; ...continue ; 40$: RTS PC ;; ...common return ; 50$: ADD #I.LEN,R0 ;; ...R0 --> Next Info Block CMP #IBLK+,R0 BLOS 40$ ;; ...more than SIZE tasks ; 60$: TST I.CPU(R0) ;; Entry in Use? BNE 70$ ;; ...yes, skip MOV T.NAM+2(R1),I.NAM+2(R0) MOV T.NAM(R1),I.NAM(R0) BEQ 70$ ;; ...idle task ; MOV T.PCB(R1),R2 ;; R2 --> PCB BEQ 70$ ;; ...oops ; ; USC001 -- support of external headers ; mov @isar6,-(sp) ;+ USC001 save old mapping mov p.rel(r2),@isar6 ;map external header mov p.hdr(r2),r2 ;get task header address bne 65$ ;if ne, task has pool header mov #140000,r2 ;otherwise, task has external header 65$: ;reference label mov h.cuic(r2),i.uic(r0) mov (sp)+,@isar6 ;- USC001 restore old mapping ; 70$: CMP I.NAM(R0),T.NAM(R1) BNE 50$ ;; ...not this task CMP I.NAM+2(R0),T.NAM+2(R1) BNE 50$ ;; ...not this task INC I.CPU(R0) ;; Else Bump CPU count BR 40$ ;; ...and exit ; SORT: MOV #IBLK,R0 ; R0 --> Info Block ; 10$: CMP I.CPU+I.LEN(R0),I.CPU(R0) BLOS 20$ ; ...order correct ; CALL 30$ ; Else Swap the Order BR SORT ; ...and retry ; 20$: ADD #I.LEN,R0 ; R0 --> Next Entry CMP #IBLK+>,R0 BHI 10$ ; ...more to do RTS PC ; Else return ; 30$: MOV I.UIC(R0),-(SP) MOV I.NAM(R0),-(SP) MOV I.NAM+2(R0),-(SP) MOV I.CPU(R0),-(SP) ; MOV I.UIC+I.LEN(R0),I.UIC(R0) MOV I.NAM+I.LEN(R0),I.NAM(R0) MOV I.NAM+2+I.LEN(R0),I.NAM+2(R0) MOV I.CPU+I.LEN(R0),I.CPU(R0) ; MOV (SP)+,I.CPU+I.LEN(R0) MOV (SP)+,I.NAM+2+I.LEN(R0) MOV (SP)+,I.NAM+I.LEN(R0) MOV (SP)+,I.UIC+I.LEN(R0) RTS PC ; DISPLY: CALL POS61 ; Position Cursor ; ...to start of area MOV #IBLK,R5 ; R5 --> Name Block ; 10$: CALL DLINE ; Display current Line ADD #I.LEN,R5 ; R5 --> Next Entry CMP #IBLK+,R5 BLOS 20$ ; ...all done TST I.CPU(R5) ; Out of tasks? BNE 10$ ; ...no, continue CALL CLR ; Else Clear to End ; 20$: RTS PC ; ...and return ; DLINE: MOV #BUFFER,R0 ; R0 --> Line Buffer MOVB #15,(R0)+ ; Begin with Carriage MOVB #12,(R0)+ ; ...return/line feed ; MOV #" [,(R0)+ ; ...square bracket MOVB I.UIC+1(R5),R1 ; Get UIC BIS #-1,R2 ; ...leading zeros CALL $CBTMG ; ...now in Ascii MOVB #',,(R0)+ ; ...and comma MOVB I.UIC(R5),R1 ; Do second half BIS #-1,R2 ; ...leading zeros CALL $CBTMG ; ...now in Ascii MOVB #'],(R0)+ ; ...square bracket MOV #" ,(R0)+ ; Pad... ; MOV I.NAM(R5),R1 ; Get RAD50 Task Name BNE 10$ ; ...exists MOV #"*I,(R0)+ ; Else force MOV #"DL,(R0)+ ; ...this MOV #"E*,(R0)+ ; ...name BR 20$ ; ...and continue 10$: CALL $C5TA ; Convert to Ascii MOV I.NAM+2(R5),R1 ; ...get 2nd half CALL $C5TA ; ...and continue 20$: MOVB #' ,(R0)+ ; Pad... ; CLR R2 ; Set up MOV I.CPU(R5),R3 ; ...to calculate MUL #100.,R3 ; ...percent DIV #RATE*60.,R2 ; ...of total CPU MOV R2,-(SP) ; Save a copy MOV R2,R1 ; ...move into R1 MOV #017012,R2 ; ...conversion flag CALL $CBTA ; Print Percentage MOV #"% ,(R0)+ ; ...percent MOVB #':,(R0)+ ; ...and fence ; MOV #1,R1 ; R1 = Bar Graph Percentage MOV (SP)+,R2 ; R2 = Real Percentage BEQ 50$ ; ...none ; 30$: CMP R2,R1 ; This much CPU used? BLO 40$ ; ...no MOVB #'=,(R0)+ ; Else indicate ADD #2,R1 ; Add 2% to Bar Graph Percentage BR 30$ ; ...and continue ; 40$: MOVB #'>,-1(R0) ; Insert Pointer ; 50$: MOVB STRDEL,(R0)+ ; Setup for Delete MOVB STRDEL+1,(R0)+ ; ...to end of line MOVB STRDEL+2,(R0)+ ; ...to end of line ; MOVB #15,(R0)+ ; Carriage return MOVB #12,(R0)+ ; ...Line Feed CALL PRINT ; ...and print the line RTS PC ; ...then return ; AST: WTSE$C EFN ; Wait for it... CALL POS221 ; Position Cursor ; ...near end of screen CALL VT100 ; Become VT100 EXIT$S ; ...and quit ; CLR: QIOW$C IO.WVB,TILUN,EFN,,,, RTS PC ; ...for VT100 ; ; PRINT: SUB #BUFFER,R0 ; R0 = Length of String QIOW$S #IO.WVB,#TILUN,#EFN,,,,<#BUFFER,R0> RTS PC ; ...and return ; POS11: QIOW$C IO.WVB,TILUN,EFN,,,, RTS PC ; ...POS TO 1,1 ; POS250: QIOW$C IO.WVB,TILUN,EFN,,,, RTS PC ; ...POS TO 2,43 ; POS61: QIOW$C IO.WVB,TILUN,EFN,,,, RTS PC ; ...POS TO 6,1 ; POS221: QIOW$C IO.WVB,TILUN,EFN,,,, RTS PC ; ...POS TO 22,1 ; VT100: QIOW$C IO.WVB,TILUN,EFN,,,, RTS PC ; ...become VT100 ; ; Pure Data Area - Tidy ... ; .PSECT TIDY,D,RO,CON ; getvec: gin$ gi.vec,vector,veclen NULL: .WORD 0,"V4 ; Null Task Name PRI: ALTP$ ; Alter Priority STRCLR: .BYTE 33,'[,'J,0 ; Clear to End of Screen STRDEL: .BYTE 33,'[,'K,0 ; Clear to End of Line STRPOS: .BYTE 33,'Y ; Position Cursor S11: .BYTE 33,'[,'1,';,'1,'f; POS to 1,1 S250: .BYTE 33,'[,'2,';,'5,'0,'f,0 ; POS to 2,43 S61: .BYTE 33,'[,'6,';,'1,'f; POS to 6,1 S221: .BYTE 33,'[,'2,'2,';,'1,'f,0 ; POS to 1,1 VT100S: .BYTE 33,'<,33,'c ; Become VT100 ; ; Impure Data Area - Grotty ... ; .PSECT GROTTY,RW,D,CON ; HEADER: .PAD 15. .ASCII /RSX-11M BL/ ID: .BLKB 2. .PAD 7. .ASCII /Top Cpu Tasks/ .PAD 10. .ASCII /R. U./<15><12><12><12> .PAD 24. .ASCII /0%/ .PAD 22. .ASCII /50%/ .PAD 22. .ASCII /100%/<15><12> .PAD 24. .ASCII /:/ .PAD 24. .ASCII /:/ .PAD 24. .ASCII /:/<15><12> HLEN =.-HEADER ; .=HEADER ; This is definitely not kosher... ; BUFFER: .=.+80. ; ...space for Line Buffer IBLK: .=.+ ; ...space for Info Block TIMBUF: .=.+16. ; ...space for Time Directive TIMER: .=.+2. ; ...space for Event Counter ; .END USE ;