OBJNAM WAITMX.LIT ; Created 16-Oct-85, edited 19-Feb-86
; by Irv Bromberg, Medic/OS Consultants, Toronto, Canada
; Replacement for WAIT.LIT, allows maximum delay to be specified for use
; with terminals connected to MUX which may in TOW locked state.
RADIX 10
VMAJOR=1
VMINOR=5
VEDIT=9
IF EQ,1
Syntax: WAITMX jobnam {maximum}
where maximum is maximum wait time in seconds, default = forever
when max expires and job's terminal has T.ECC(TCB) set we flush echo chars
so CPU not sluggish in TTYIN echo wait loop.
GetJob: SUB #6,SP
FILNAM @SP,XXX
MOV JOBTBL,A1
SchJob: CMP @A1,#-1
JEQ NoJob
MOV (A1)+,JCB
MOV JOBNAM(JCB),Dtemp
CMP Dtemp,@SP
BNE SchJob
MOV #-1,Delay ; set up maximum delay = forever
BYP
LIN ; delay parameter passed?
BEQ Loop ; no, use default delay
CMPB @Buffer,#', ; allow comma as separator
BNE GetNum ; but not required
INC Buffer ; bypass comma
BYP ; bypass possible additional whitespace
GetNum: NUM ; yes, make sure we have a number here
JNE Syntax ; nope, syntax error
GTDEC ; get delay period
JMI Syntax
TST Number
JLE Syntax ; <=0 means syntax error
CMP Delay,#10000 ; lets make this reasonable!
JHI Syntax
MUL Delay,#5 ; x5 because we wait 0.2 secs each time round
Loop: MOVW JOBSTS(JCB),Dtemp
ANDW #J.MSG!J.EXW!J.SLP!J.TIW,Dtemp
BNE Quit
SLEEP #2000
CTRLC Quit
DBF Delay,Loop
TYPE <%Timeout - wait aborted>
MOV JOBTRM(JCB),Dtemp ; check that terminal doesn't have ECC set
BEQ 10$ ; whoops, not attached!
MOV Dtemp,TCB
MOV T.ECC(TCB),Number
BEQ 10$
CLR T.ECC(TCB)
TYPE <, flushed>
DCVT 0,OT$TRM!OT$LSP!OT$TSP
TYPE <echo character>
CMP Number,#1
BEQ 10$
TYPE <s>
10$: CRLF
Quit: EXIT
NoJob: TYPECR <?Nonexistent job>
EXIT
END