.title Job Monitoring ; DECUS C Calling Format ; ; jsr r5,csv$ ;save r2,r3, and r4 ; ;r5 is parameter base ; ;c$pmtr(r5) is first argument ; ;c$pmtr+2(r5) is second argument ; ;... ; ;return args in r0 ; ... ; user code ; ... ; ; jmp cret$ ;restore r2-r5 and return ; rts pc ;does the same (cret$ follows csv$) ; ; csv$ and cret$ need be used only if arguments are used ; .include "os.mac" .if ne rt$sys ;rt-11 specific .sbttl JOBMON and JBABRT routines ; JOBMON dumby routine ; ; JABORT returns the job number of any ; RT-11 job which terminates. ; ; JOBSTS return != 0 if job is running ; return == 0 if job has terminated ; ; jobmon(); ; ; jabort(); ; ; jobsts(jobnum); ; .psect c$code jobmon:: ;RT-11 does non support the jobini: rts pc ;job monitoring functionality jobsts:: mov #gtabrt,r0 mov 2(sp),4(r0) ;load job number dec 4(r0) ;correct job number emt 375 ;get status bcc 1$ ;running clr r0 1$: rts pc ; Scan the Jobs that have sent us messages ; and verify they are still running. ; If not then report the job as aborted. jbabrt:: jsr r5,csv$ ;save a few registers clr r3 ;job number mov #jobnam,r2 ;job name ;.gtjb #gtabrt,#3$,#jobnam 1$: mov #gtabrt,r0 mov r2,4(r0) ;jobnam tst (r2) beq 2$ ;invalid job name emt 375 bcc 2$ mov r3,r0 ;job number jsr pc,jbcomp ;job completed 2$: add #6,r2 ;update jobnam address add #2,r3 ;update job number cmp r3,#2*8. blt 1$ mov #8.,r2 ;possible jobs mov #ablist,r1 3$: movb (r1)+,r0 bne 4$ dec r2 bne 3$ clr r0 ;no completed jobs rts pc 4$: bis #5*400,r0 ;level 5 = 'logged off' clrb -(r1) ;reported completed job rts pc ;return aborting job number .psect c$data gtabrt: .byte 1,20 ;.gtjb .word 1$ .word jobnam 1$: .blkw 12. .page .sbttl Job Completed .psect c$code jbcomp: bic #^c<16>,r0 ;jobnum = 0,2,4,6,10,12,14,16 inc r0 movb r0,ablist(r0) ;enter in list dec r0 mov r0,r1 asl r0 add r0,r1 add #jobnam,r1 clr (r1)+ ;clear logical name clr (r1)+ clr (r1)+ rts pc .sbttl Termination List .psect c$data ablist: .blkb 8. ;list of aborts ; The Unused killjob function. .psect c$code killjob:: ;RT-11 does not support rts pc ;the kill job functionality ; jb$$sn Save Logical Name ; ; R0 - job number ; (R1) - job name .psect c$code jb$$sn:: bic #^c<16>,r0 ;0,2,4,6,10,12,14,16 mov r0,-(sp) asl r0 add (sp)+,r0 add #jobnam,r0 mov (r1)+,(r0)+ ;copy logical name into table mov (r1)+,(r0)+ mov (r1)+,(r0)+ rts pc .psect c$data jobnam: .blkw 8. * 3. ;program logical names ; jb$$gn Get Logical Name ; ; R0 - job number ; (R1) - job name .psect c$code jb$$gn:: bic #^C<16>,r0 ;jobnum = 0,2,4,6,10,12,14,16 mov r0,-(sp) asl r0 add (sp)+,r0 add #jobnam,r0 mov (r0)+,(r1)+ ;copy logical name beq 1$ ;invalid logical name mov (r0)+,(r1)+ mov (r0)+,(r1)+ tst (pc)+ ;valid, clear 'C' 1$: sec ;invalid, set 'C' rts pc .endc .if ne ts$sys ;tsx-plus specific .sbttl JOBMON and JBABRT routines ; JOBMON initializes the monitoring process ; ; JABORT returns the job number of any ; TSX+ job which terminates. ; ; JOBSTS return != 0 if job is running ; return == 0 if job has terminated ; ; jobmon(jobnum, level); /* jobnum = 0, all jobs */ ; ; jabort(); ; ; jobsts(jobnum); ; .psect c$code jobmon:: mov 2(sp),jbmnum ;set job to monitor mov 4(sp),abtlvl ;abort level jobini: mov #jbmemt,r0 ;enable job monitoring emt 375 rts pc jobsts:: mov #jbsemt,r0 movb 2(sp),2(r0) ;set job number beq 1$ emt 375 ;get status bcc 2$ ;running 1$: clr r0 ;terminated 2$: rts pc jbabrt:: clr r0 cmp about,abin ;any terminations beq 1$ ;no - exit mov about,r1 mov ablist(r1),r0 ;get terminating job add #2,r1 bic #^c<76>,r1 mov r1,about 1$: rts pc ;return aborting job .psect c$data jbmemt: .byte 0,157 ;job monitor argument block jbmnum: .word 0 ;job to monitor (default = all) .word jbcomp ;completion routine jbsemt: .byte 1,144 ;job status argument block .word 0 ;job number .word 1$ 1$: .blkw 2 .page .sbttl Job Monitoring Completion routine ; completion routine is entered with: ; ; r0 - low byte is job number ; high bit of word is set if ; the status came from a job or ; clear if the status came from ; the system ; ; r1 - contains the status code ; 1 - job has been initiated ; 2 - job has logged in using the LOGON program ; 3 - job has started running a job ; 4 - job has return control to the keyboard monitor ; 5 - job has logged off ; ; ; Terminations are checked for uniquenes ; .psect c$code jbcomp: cmp abtlvl,r1 ;check status level bhi 5$ ;not high enough mov r0,-(sp) ;lo-byte is job movb r1,1(sp) ;hi-byte is status mov (sp)+,r0 mov about,r1 ;next abort to be read br 3$ 1$: cmpb r0,ablist(r1) ;job match ? bne 2$ ;no - skip cmp r0,ablist(r1) ;higher level ? bhi 4$ ;yes - replace lower br 5$ ;no - exit 2$: add #2,r1 bic #^c<76>,r1 3$: cmp r1,abin ;end of list ? bne 1$ ;no - loop 4$: mov r0,ablist(r1) ;place job number in list add #2,r1 ;update pointer bic #^c<76>,r1 cmp r1,about ;room ? beq 5$ ;no - skip update mov r1,abin 5$: rts pc .sbttl Termination List .psect c$data abtlvl: .word 4 ;abort code level (default = 4) abin: .word 0 ;input pointer about: .word 0 ;readout pointer ablist: .blkw 32. ;list of aborts ; The killjob function has been updated to include ; code provided by Billy Youdelman. ; ; ; This code will kill any job for TSX+ versions down ; to V6.0 using an undocumented proceedure. ; .psect c$code $inkmn = 10000 ; LSW4 bit flags TSKMON is executing ts.ver = -32. ; .gval offset to TSX version number killjob:: mov #gval,r0 ; .gval TSX version emt 375 bcs 1$ ; this doesn't work before V6.0 mov r0,tsxver ; save version number 1$: cmp tsxver,#631. ; will documented kill emt work ? blo 2$ ; no - use undocumented mov 2(sp),kljbnm ; job number to kill mov #kljemt,r0 ; documented kill emt emt 375 rts pc 2$: mov #kmnon,r0 ; set the "in KMON" bit in LSW4 emt 375 ; so the following emt can be called mov 2(sp),undjob ; pass job_number * 2 (word indexing) asl undjob mov #undkil,r0 ; undocumented kill emt emt 375 mov #kmnoff,r0 ; now clear the "in KMON" bit emt 375 rts pc .psect c$data kljemt: .byte 2,132 ;kill a job kljbnm: .word 0 ;job number to kill undkil: .byte 0,126 ; undocumented TSKMON kill_a_job emt .word 5 undjob: .word 0 ; "job" = tsx_line_number * 2 kmnoff: .byte 3,130 ; clear $INKMN (in KMON) bit in .word 4 ; TSX's Line_Status_Word_4 .word $inkmn kmnon: .byte 2,130 ; set $INKMN (in KMON) bit in .word 4 ; TSX's Line_Status_Word_4 .word $inkmn gval: .byte 0,34 ; .gval argument block .word ts.ver ; .gval offset to TSX version number tsxver: .word 0 ; TSX version number .endc .page .sbttl Initializer and Finalizer Code ; The initializer calls jobini to ; initialize the job monitor. .psect $init .psect $init$ .word jobini ;initalizer routine .psect $init. ; The finalizer is not required. .psect $finl .psect $finl$ .psect $finl. .end