.PSECT KILL .TITLE KILL ABORT ALL TASKS UTILITY .IDENT /V2.1/ .ENABL LC ;======================================================================== ; KILL.MAC VERSION 2.0 ; ; Phil Hoffman ; Department of Chemistry ; Michigan State University ; East Lansing, MI 48824 ; 8-April-1983 ;------------------------------------------------------------------------ ; KILL is a general purpose utility program, whose function is to abort ; all tasks currently running for the terminal from which KILL was requested. ; This way, the user does not need to know the name of a specific task ; in order to abort it (a confusion which has arise through a mixture of ; CCL installation of tasks on our system with a variety of /TASK= ; naming conventions.) Clearly, if more than one task is running from ; the user's terminal at a given time, and the user does NOT wish to ; abort all of them, specific task names must be known. ; ; KILL is a privileged task since it must examine the system tables to ; which tasks are attributable to the user's terminal, and is installed ; under the name ...KIL . When running, KILL specifically does NOT issue ; abort directives, for itself, MCR..., or ...MCR . ;------------------------------------------------------------------------ ; MODIFICATION HISTORY ; ; Version 2.0 -- Superfluous GTSK$ directive removed ; ; Version 2.1 -- Calls to $LOCKL AND $UNLKL removed and replaced w/ ; direct used os $SWSTK ;======================================================================== .MCALL TCBDF$ .MCALL MRKT$,WTSE$,ABRT$,WSIG$S,DIR$,EXIT$S ;------------------------------------------------------------------------ ; Local Definitions, DPB's, and working storage ;------------------------------------------------------------------------ TCBDF$ ; Define Task Control Block codes .PSECT KILL ; EFN = 1 ; Event flag for time delay MARK: MRKT$ EFN,5.,2. ; 5. sec delay during ABOALL WAIT: WTSE$ EFN ; Wait corresponding to MARK ABORT: ABRT$ ; Abort cmd file and its tasks ; ALSTSZ = 10. ; # of task names to fit in abo list ABOLST: .BLKW 2*ALSTSZ+1 ; Allocate the abort task list DELAY: .BLKW 1 ; Used to count # tsks mrkd for abo RSRV1: .RAD50 /.../ ; Set aside reserved words for ... RSRV2: .RAD50 /MCR/ ; and MCR ;======================================================================== ; Entry Point ;======================================================================== KILL:: MOV $TKTCB,R0 ; Get TCB address for this task MOV T.UCB(R0),R4 ; Get TI: UCB address 2$: MOV U.RED(R4),R4 ; Follow redirect chain CMP R4,U.RED(R4) ; End of chain reached? BNE 2$ ; NE => No - continue ; EQ => Yes - TI: UCB addr in R4 ;------------------------------------------------------------------------ ; Begin searching the system lists for all tasks attributable to this ; terminal, excluding ...MCR, MCR..., and this task. ;------------------------------------------------------------------------ 4$: CLR DELAY ; Clear the delay flag CALL $SWSTK,21$ ;; Switch stacks MOV $TSKHD,R1 ;; Get the addr of first task header MOV #ABOLST,R2 ;; Point to the abort list MOV #ALSTSZ,R3 ;; Set counter for list size ;------------------------------------------------------------------------ ; Fill the abort list with the names of all tasks attributed to ; this terminal to a maximum of ALSTSZ. ;------------------------------------------------------------------------ CLR (R2)+ ;; clear the abo. list counter 6$: TST T.STAT(R1) ;; Is the task pointed to active? BMI 16$ ;; No -- get the next one CMP R4,T.UCB(R1) ;; Active - is it from this term? BNE 16$ ;; No -- keep searching ;------------------------------------------------------------------------ ; Check this task name against MCR... and ...MCR. If it matches either ; one, do not put it into the abort list ;------------------------------------------------------------------------ CMP T.NAM(R1),RSRV1 ;; First word ...? (for ...MCR) BNE 8$ ;; No - check for MCR... CMP <2+T.NAM>(R1),RSRV2 ;; Yes - second word MCR? (for ...MCR) BEQ 16$ ;; Yes - skip it BR 10$ ;; No - check it against this task ;; 8$: CMP T.NAM(R1),RSRV2 ;; First word MCR? (for MCR...) BNE 10$ ;; No - check for this task CMP <2+T.NAM>(R1),RSRV1 ;; Yes - 2nd word ...? (for MCR...) BEQ 16$ ;; Yes - skip it BR 12$ ;; No - fair game to abort ;; 10$: CMP T.NAM(R1),T.NAM(R0) ;; First word for this task? BNE 12$ ;; No - fair game to abort CMP <2+T.NAM>(R1),<2+T.NAM>(R0) ;; Yes - second word match? BEQ 16$ ;; Yes - skip it ;; 12$: BIT #,T.STAT(R1) ;; Run down or abo msg output? BNE 14$ ;; Yes - set the delay BIT #,T.ST2(R1) ;; Halted or mrked for abo? BNE 14$ ;; Yes - set the delay ;; MOV T.NAM(R1),(R2)+ ;; Put 1st word of name into abo list MOV <2+T.NAM>(R1),(R2)+ ;; and the second word INC ABOLST ;; and increment the lst counter BR 18$ ;; See if we've filled the list ;; 14$: INC DELAY ;; Increment the delay word ;; 16$: MOV T.TCBL(R1),R1 ;; point to next task header TST T.TCBL(R1) ;; Is this the null task? BEQ 20$ ;; Yes - quit BR 6$ ;; No - continue checking ;; 18$: SOB R3,16$ ;; If list isn't full keep going ;------------------------------------------------------------------------ ; Either the list is full, or the null task has been found ;------------------------------------------------------------------------ 20$: RETURN ;; Return from system state 21$: MOV ABOLST,R3 ; Get the list counter BEQ 26$ ; No point if the list is empty TST DELAY ; Are there tasks on their way out? BEQ 22$ ; No - clobber according to the list ;------------------------------------------------------------------------ ; There are some tasks marked for abort, but not clobbered yet. Wait ; for 5. seconds (use the general timeout and wait dpb's for this) ; then check the system lists again ;------------------------------------------------------------------------ DIR$ #MARK ; Issue 5. second count-down DIR$ #WAIT ; Wait for it BR 4$ ; And start all over again ;------------------------------------------------------------------------ ; Begin clobbering from the abort list ;------------------------------------------------------------------------ 22$: MOV #,R1 ; Point to the start of the abo list MOV #ABORT,R2 ; and point to the ABRT$ DPB 24$: MOV (R1)+,A.BTTN(R2) ; Move the task name ( 2 words) MOV (R1)+,<2+A.BTTN>(R2) ; into the ABRT$ DPB DIR$ R2 ; and abort the task WSIG$S ; Wait for completion of the kill SOB R3,24$ ; loop until done ;------------------------------------------------------------------------ ; Continue searching system lists and aborting tasks until no more ; are found, in case there were more tasks that would fit in the list ; on one pass, or in case something started up asynchronously and ; wasn't found in the task list before. ;------------------------------------------------------------------------ BR 4$ ; and around we go again ;------------------------------------------------------------------------ ; There are no more tasks to abort. ;------------------------------------------------------------------------ 26$: EXIT$S ; .END KILL