.TITLE ATP .IDENT /V2.02/ .ENABL LC ;******************************************************************* ; ; ATP.TSK ; ; Tabulate active task list with priorities. ; Syntax: ; ; >ATP Show list for all terminals ; >ATPT Show list for TI: only ; ; Version: V1 March 1979 ; Version: V2 June 1982 ; ; Modifications: ; ; 6-Sep-81 SMT ; Don't show loader (. LDR.) at head of list. ; ; 7-Sep-81 SMT ; Add ATPT option ; ; Steve Thompson ; School of Chemical Engineering ; Olin Hall ; Cornell University ; Ithaca NY 14853 ; ;******************************************************************* .MCALL EXIT$S,DIR$,QIOW$,GMCR$ .MCALL EXST$ MAXENT = 40. ; Maximum number of entries in buffer LUN = 1 ; TI: I/O lun EFN = 1 ; Event flag for I/O ; ; MACROS ; .MACRO ATPDF$,L,B .ASECT .=0 .BLKB 1 ; Unused byte A.PRI:'L' .BLKB 1 ; Task's current priority A.TNAM:'L' .BLKW 2 ; Task name in radix-50 A.UCB:'L' .BLKW 1 ; UCB Address of owner task A.LGTH='B'. ; Control block length .PSECT .MACRO ATPDF$,X,Y .ENDM .ENDM ATPDF$ ; Define internal control block offsets .PAGE .NLIST BEX .ENABL LC ; ; LOCAL DATA STORAGE ; ATPBUF: .BLKB ; Internal accounting list buffer ; (must start on word boundary) NUMENT: .WORD MAXENT ; Number of entries in list GMCR: GMCR$ ; Get command line dpb OUTBUF=GMCR+2 ; Output buffer .EVEN DPBOUT: QIOW$ IO.WVB,LUN,EFN,,,, ; Output dpb DPBATT: QIOW$ IO.ATT,LUN,EFN ; Attach TI: DPB DPBDET: QIOW$ IO.DET,LUN,EFN ; Detach TI: DPB TIUCB: .WORD 0 ; TI: UCB address EXST: EXST$ EX$SUC .PAGE $ATPEP: ; Xfer address DIR$ #GMCR ; Zap any command line there may be CLR TIUCB ; Assume display of all terminals CMPB OUTBUF+3,#'T ; Show just my terminal (ATPT)? BNE 1$ ; If NE no, all terminals MOV $TKTCB,R0 ; Get our TCB address MOV T.UCB(R0),TIUCB ; Save TI: UCB address 1$: ; Ref. label ; ; Buffer task list in internal buffer. *NOTE* The code here assumes some ; of the ATPDF$ offsets (see above). ; CALL $SWSTK,100$ ; Switch stacks MOV #ATPBUF,R0 ;; Set internal buffer address MOV $TSKHD,R1 ;; Set task list address MOV T.TCBL(R1),R1 ;; Skip the loader 90$: TST T.TCBL(R1) ;; Null task TCB? BEQ 94$ ;; If EQ, end of list BIT #T2.ABO,T.ST2(R1) ;; Task being aborted? BNE 92$ ;; If NE yes, skip it BIT #,T.STAT(R1) ;; Active or not being aborted? BNE 92$ ;; If NE no, skip it TST TIUCB ;; Show all terminals? BEQ 91$ ;; If EQ yes CMP T.UCB(R1),TIUCB ;; No, right terminal? BNE 92$ ;; If NE no, skip it 91$: CLRB (R0)+ ;; Zap unused byte MOVB T.PRI(R1),(R0)+ ;; Save task's current priority MOV T.NAM(R1),(R0)+ ;; Save task name MOV T.NAM+2(R1),(R0)+ ;; MOV T.UCB(R1),(R0)+ ;; Save TI: UCB address DEC NUMENT ;; Can we take any more entries? BLE 94$ ;; If LE, no 92$: MOV T.TCBL(R1),R1 ;; Get next TCB BR 90$ ;; Loop 94$: RETURN ;; No, return to user state 100$: NEG NUMENT ; Calculate number of entries in buffer ADD #MAXENT,NUMENT ; BEQ EXIT ; Exit if nothing (!!) ; ; Format and print internal version of list. ; DIR$ #DPBATT ; Attach to TI: MOV #ATPBUF,R5 ; Set address of first entry MOV #OUTBUF,DPBOUT+Q.IOPL ; Set address of output buffer 110$: MOV #OUTBUF,R0 ; Get output buffer address MOV A.TNAM(R5),R1 ; Convert task name to ASCII CALL $C5TA ; MOV A.TNAM+2(R5),R1 ; 2nd half CALL $C5TA ; MOVB #40,(R0) ; Insert 2 spaces MOVB (R0)+,(R0)+ ; MOV A.UCB(R5),R3 ; Get TI: device UCB address CALL $FMTDV ; And format device name MOVB #11,(R0)+ ; Insert a tab CLR R1 ; Clear R1 for priority BISB A.PRI(R5),R1 ; Get priority CLR R2 ; Set no leading zeroes CALL $CBDMG ; Convert to decimal MOVB #'.,(R0)+ ; Add a decimal point SUB #OUTBUF,R0 ; Calculate message length MOV R0,DPBOUT+Q.IOPL+2 ; Put it in the DPB DIR$ #DPBOUT ; And print it ADD #A.LGTH,R5 ; Point to next area in buffer DEC NUMENT ; Any entries left? BGT 110$ ; Yes, loop DIR$ #DPBDET ; Detach TI: EXIT: DIR$ #EXST ; Exit with correct status EXIT$S ; Just in case .END $ATPEP