.TITLE BAPSOJ .IDENT /V3.02/ .ENABL LC .NLIST BEX ;************************************************************************** ; ; BAPSOJ.MAC ; ; This module services the start of job request. The logfile and ; history file are created here. If /NOLOGFILE was specified when ; the job was submitted, we do not create log and history files ; and in addition do not set up the U.BTCB field of the TCB so ; that all output done by the job will be discarded in the driver ; without waking up the Batch Processor. ; If /NOPRINTER was specified, the log and history files are ; created in the user's directory (or the default at the time of ; the submission); otherwise they are created in the default ; system logfile directory. ; ;-------------------------------------------------------------------------- ; ; The start-of-job packet sent by the Queue Manager has the following ; format (there is only one start-of-job packet for batch jobs, ; unlike print jobs which receive two). I use the offsets Q$Jxxx ; since they are convenient and is a lot easier than trying to find ; out what symbolic offsets are used by the Queue Manager (which is ; a pain if you only have the object libraries). ; ; Location Offset Contents ; -------- ------ -------- ; ; Word 1 Q$JFUN Contains function code (QP.SOJ) ; Word 2 Q$JUIC UIC of Job ; Word 3 Q$JNAM Radix-50 Jobname, word 1 of 3 ; Word 4 Q$JNAM+2 Radix-50 Jobname, word 2 of 3 ; Word 5 Q$JNAM+4 Radix-50 Jobname, word 3 of 3 ; Word 6, byte 1 Q$JATT Job Attributes byte ; byte 2 Q$JUNT Unit number of user's SY: device ; Word 7 Q$JDEV Name of user's SY: device (ASCII) ; Word 8 Q$PRIN Radix-50 Print Queue name, word 1 of 2 ; Word 9 Q$PRIN+2 Radix-50 Print Queue name, word 2 of 2 ; Word 10 - Unused ; Word 11 - Unused ; Word 12 - Unused ; Word 13 - Unused ; ; The following bits in the attributes byte are important to this ; routine: ; ; QJ$SPL Logfile should be spooled ; ; QJ$LOG Logfile should be generated ; ;-------------------------------------------------------------------------- ; ; Version: V3.02 (Version V3.00 April 1983) ; ; Modification History ; ==================== ; ; SMT303 16-JUL-83 Steve Thompson ; Support for new close/reopen log/hist file ; code in BAPROT ; ; SMT305 27-JUL-83 Steve Thompson ; Make console messages appear even if /NOCOTERM ; is specified. ; ;-------------------------------------------------------------------------- ; ; Steve Thompson ; School of Chemical Engineering ; Olin Hall ; Cornell University ; Ithaca ; NY 14850 ; (607) 256 4616 (office) ; (607) 256 3895 (computer room) ; ;************************************************************************** .MCALL DIR$, ENAR$S, DSAR$S .MCALL MRKT$S, STSE$S .MCALL OFNB$W, PUT$ ; ; Text messages. ; COSOJ: .ASCII /Start of Job / COSOJJ: .ASCII /[GGG,MMM] / .ASCII / on Batch Stream / COSOJV: .ASCIZ /VTNN:/ SOJB: .ASCIZ /000000/ HISTF: .ASCII /************ H I S T O R Y O F B A T C H J O B "/ HISTFJ: .ASCII /J O B J O B J O B/ .ASCII / " ***********/ .ASCII / Time / .IF DF,B3$ACC .ASCII / CPU Time / .ENDC ; DF,B3$ACC .ASCII /Origin/ HISTSZ=.-HISTF SOJHST: .ASCII /Start of Job / SOJHSJ: .ASCIZ /JOBJOBJOB/ HELLO: .ASCII /HEL / HELLOU: .ASCIZ /[GGG,MMM]/ ; ; Error messages. ; ERLOG: .ASCII /*FATAL* Failed to create Logfile/ ERLOGS=.-ERLOG ERHST: .ASCII /*FATAL* Failed to create History File/ ERHSTS=.-ERHST ERHEL: .ASCIZ /Job Failed to Start/ .EVEN .PAGE .SBTTL MAIN LINE CODE ;+ ; **-$SOJEP-Start of job processor. ; ; Note that the Queue Manager sends only one start of job packet ; for batch jobs, unlike print jobs which get two. ; ;- $SOJEP::TSTB JOBFLG ; Job already executing? BEQ 1$ ; If EQ no RETURN ; Yes, ignore it 1$: ; Ref. label ; ; If logins are disabled, wait until they are enabled. ; 2$: BIT #FE.NLG,$FMASK ; Logins disabled? BEQ 3$ ; If EQ no MRKT$S #NLGEFN,#10.,#2 ; Mark time for 10 seconds BCS 2$ ; Just in case STSE$S #NLGEFN ; Wait for time to elapse BR 2$ ; See if logins now enabled 3$: ; Ref. label ; ; Set initial flags, etc. ; DSAR$S ; Make sure AST recognition off CLRB CMDFLG ; Show command buffer empty CLRB ERRFLG ; Assume no errors CLRB ABOFLG ; Reset requested abort flag CLRB PAUFLG ; Show not paused MOVB SP,JOBFLG ; Show job executing MOVB SP,CPUFLG ; Allow CPU time in history file MOVB SP,ECHFLG ; Default is *ECHO MOVB SP,QUIFLG ; Default is *NOISY MOVB SP,NBRFLG ; Default is *NUMBER CLRB LOGOPN ; Show logfile not open CLRB HSTOPN ; Show history file not open CLR PAGE ; Start at beginning of file MOV #$LINPP,LINE ; Force a heading on page 1 ; ; Copy the receive buffer to the start-of-job buffer so that we can ; remember the information about this job. Convert the jobname to ; ASCII. ; MOV #SOJBUF,R0 ; Get job info. buffer address MOV #RCVBUF+4,R1 ; Get received info. address MOV #13.,R2 ; Number of words to copy 10$: MOV (R1)+,(R0)+ ; Move a word DEC R2 ; Done yet? BGT 10$ ; If GT no, loop MOV #JOBNAM,R0 ; Get buffer address for jobname MOV SOJBUF+Q$JNAM,R1 ; Get word 1 of Radix-50 Jobname CALL $C5TA ; Convert to ASCII MOV SOJBUF+Q$JNAM+2,R1 ; Repeat for word 2 CALL $C5TA ; MOV SOJBUF+Q$JNAM+4,R1 ; Repeat for word 3 CALL $C5TA ; ; ; Set our TCB address in the virtual terminal UCB so that the driver ; will acknowledge our existence (but only if we are building a ; logfile). ; MOV VTUCB,R0 ; Get UCB address BITB #QJ$LOG,SOJBUF+Q$JATT ; Logfile required? BEQ 15$ ; If EQ no MOV $TKTCB,U.BTCB(R0) ; Fill in our TCB address 15$: CLR U.BMEM(R0) ; No memory limit yet CLRB U.BPRI(R0) ; No priority limit yet ; ; Announce the start of this job on the console terminal. ; MOV #COSOJJ,R2 ; Get buffer address for jobname MOV SOJBUF+Q$JUIC,R3 ; Get job UIC MOV R3,JOBUIC ; Save it MOV #1,R4 ; Include separators and zeroes CALL .PPASC ; Convert UIC to ASCII MOV #JOBNAM,R1 ; Point to ASCII jobname MOV #HISTFJ,R3 ; Another place to put it MOV #SOJHSJ,R4 ; And another... MOV #9.,R0 ; Get its length 20$: MOVB (R1),(R2)+ ; Copy a byte MOVB (R1),(R3)+ ; Copy same byte again MOVB #SPA,(R3)+ ; and a space MOVB (R1)+,(R4)+ ; and again... DEC R0 ; Done yet? BGT 20$ ; If GT no, loop MOV #COSOJV,R0 ; Get buffer address for batch device MOV VTUCB,R3 ; Get stream UCB address CALL $FMTDV ; Format as ddnn: SUB #COSOJ,R0 ; Calculate message length MOV #COSOJ,COWRIT+Q.IOPL ; Set up message address in DPB MOV R0,COWRIT+Q.IOPL+2 ; Set up message length in DPB DIR$ #COWRIT ; Send out message ; ; Set up the initial exit status conditions. ; MOV #1,EXSEQ ; Turn EQ test on MOV #EX$SUC,EXSEQ+2 ; EQ test requires EX$SUC status CLR EXSGT ; Turn GT test off CLR EXSGT+2 ; CLR EXSLT ; Turn LT test off CLR EXSLT+2 ; ; ; Let the user know, if he/she is logged on. ; .IF DF,B3$MSG MOV R0,R1 ; Copy message length MOV #COSOJ,R0 ; Set message address CALL MESSAG ; Do it .ENDC ; DF,B3$MSG ; ; Set up the data structures for creating the log and history files. The ; filename block is filled in directly so that we can open by filename ; block. ; ; First, the name/type/version fields. ; BITB #QJ$LOG,SOJBUF+Q$JATT ; Logfile required? BNE 29$ ; If NE yes JMP 55$ ; If no, bypass all file logic 29$: MOV #SOJBUF+Q$JNAM,R0 ; Point to Radix-50 jobname MOV #LOGFDB+F.FNB+N.FNAM,R1 ; Point to logfile name in FDB MOV #HSTFDB+F.FNB+N.FNAM,R2 ; Point to history file name in FDB MOV #3,R3 ; Set number of words to move 30$: MOV (R0),(R1)+ ; Move word to logfile FNB MOV (R0)+,(R2)+ ; Move word to history file FNB DEC R3 ; Done yet? BGT 30$ ; If GT no, loop MOV #^RLOG,(R1)+ ; Set type of logfile to .LOG MOV #^RHST,(R2)+ ; Set type of history file to .HST INC (R1) ; Update version number fields INC (R2) ; (this is in case two jobs of the ; same name run consecutively. If the ; first logfile has not printed, ; OFNB$W would overwrite it if it were ; not for these statements) ; ; Now set the device. ; ADD #,R1 ; Skip to device name fields ADD #,R2 ; BITB #QJ$SPL,SOJBUF+Q$JATT ; Logfile to be printed? BNE 32$ ; If NE yes, use system UFD CLR R3 ; Get user's SY: device number BISB SOJBUF+Q$JUNT,R3 ; MOV SOJBUF+Q$JDEV,(R1) ; Set user's SY: device for logfile MOV (R1)+,(R2)+ ; Set user's SY: device for hst. file MOV R3,(R1)+ ; Set user's SY: number for logfile MOV R3,(R2)+ ; Set user's SY: number for hst. file BR 34$ ; Go set UFD 32$: MOV $DNAM,(R1) ; Set device name for logfile MOV (R1)+,(R2)+ ; Set device name for history file MOV $DEVU,(R1) ; Set device unit for logfile MOV (R1)+,(R2)+ ; Set device unit for history file 34$: ; Ref. label ; ; Now set the directory. ; MOV BINUFD,R1 ; Get binary UFD (assume system UFD) BITB #QJ$SPL,SOJBUF+Q$JATT ; Write into user's directory? BNE 36$ ; If NE no MOV JOBUIC,R1 ; Yes, get binary UFD 36$: CALL .WDFUI ; Write into FSR as default directory MOV #LOGFDB,R0 ; Get FDB address in R0 MOV R0,R1 ; Point to filename block ADD #F.FNB,R1 ; CALL .GTDID ; Get directory ID information BCC 38$ ; If CC, good CALLR EMLOG ; If CS, illegal directory, or ; directory file did not exist 38$: MOV #HSTFDB,R0 ; Repeat for history file FDB MOV R0,R1 ; ADD #F.FNB,R1 ; CALL .GTDID ; BCC 39$ ; Just in case CALLR EMHST ; 39$: ; Ref. label ; ; Create the logfile and the history file; write initial messages to ; the file. ; CLR LOGCNT ; Zero SAVAST logfile line counter CLR HSTCNT ; Zero SAVAST history file line counter CLR LOGFDB+F.FNB+N.FID ; Don't open by file ID CLR HSTFDB+F.FNB+N.FID ; ditto MOV JOBUIC,R1 ; Set default UIC CALL .WDFUI ; MOV JOBUIC,R1 ; Get job UIC CALL .WFOWN ; Give file ownership to job's UIC OFNB$W #LOGFDB ; Create logfile by filename block BCC 40$ ; If CC, good CALLR EMLOG ; Else send error and abort job 40$: OFNB$W #HSTFDB ; Create history file by filename block BCC 50$ ; If CC, good MOV #LOGFDB,R0 ; Error, so must delete logfile CALL .DLFNB ; Do it CALLR EMHST ; Send error and abort job 50$: INCB LOGOPN ; Logfile now open INCB HSTOPN ; History file now open DIR$ #SAVON ; Start flushing cycle PUT$ R0,#HISTF,#HISTSZ ; Write title directly (because it's ; not in the standard history file ; message format) INC HSTCNT ; Don't forget to count this line MOV #^RSYS,ORIGIN ; Set origin code=SYS MOV #SOJHST,R1 ; Get first line of file CALL WRHIST ; Write to history file ; (NB ASTs are disabled here) ; ; Prepare for job execution. ; CALL VTREAD ; Issue read to driver 55$: MOV #HELLOU,R2 ; Get place in HELLO cmd. for UIC MOV JOBUIC,R3 ; Get job UIC MOV #1,R4 ; Include separators and zeroes CALL .PPASC ; Convert UIC to ASCII .IF DF,B3$PAG CLR PAGLIM ; No output limit yet CLRB PAGFLG ; Prevent ...HEL from being ; aborted (we don't have an output ; limit yet - this comes with the ; first file). .ENDC ; DF,B3$PAG ; ; Log in the job. ; ENAR$S ; Enable AST recognition MOV #HELLO,R0 ; Point to ASCIZ command string CALL GIVMCR ; Send to MCR and wait for it TSTB MCRERR ; Spawn error? BNE EMHEL ; If NE yes MOV VTUCB,R0 ; Get batch stream UCB address BIT #U2.LOG,U.CW2(R0) ; Did job log on OK? BNE EMHEL ; If NE logon failed for some reason RETURN ; Return to root and get the first ; sub-job packet from QMG... .PAGE ;+ ; **-Error Processing. ; ;- EMLOG: MOV #ERLOG,COWRIT+Q.IOPL ; Error creating logfile MOV #ERLOGS,COWRIT+Q.IOPL+2 ; BR EMCOM ; Continue in common code EMHST: MOV #ERHST,COWRIT+Q.IOPL ; Error creating history file MOV #ERHSTS,COWRIT+Q.IOPL+2 ; BR EMCOM ; Continue in common code EMHEL: DSAR$S ; Disable AST recognition MOV #ERHEL,R1 ; Send "Job failed to start" to CALL WRHIST ; history file ENAR$S ; Enable AST recognition BR EMCOM1 ; Set error flag and return EMCOM: DIR$ #COWRIT ; Write message to CO: EMCOM1: INCB ERRFLG ; Set error flag RETURN ; Return to root .END