	.TITLE     ***  BDSLCT -- SELECT NEXT JOB TO PROCESS

 

 

 

 

/

/ COPYRIGHT (C) 1976

/ DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.

/

/ THIS SOFTWARE IS FURNISHED UNDER A LICENSE FOR USE ONLY

/ ON A SINGLE COMPUTER SYSTEM AND MAY BE COPIED ONLY WITH

/ THE INCLUSION OF THE ABOVE COPYRIGHT NOTICE.  THIS

/ SOFTWARE, OR ANY OTHER COPIES THEREOF, MAY NOT BE PRO-

/ VIDED OR OTHERWISE MADE AVAILABLE TO ANY OTHER PERSON

/ EXCEPT FOR USE ON SUCH SYSTEM AND TO ONE WHO AGREES TO

/ THESE LICENSE TERMS.  TITLE TO AND OWNERSHIP OF THE

/ SOFTWARE SHALL AT ALL TIMES REMAIN IN DEC.

/

/ THE INFORMATION IN THIS DOCUMENT IS SUBJECT TO CHANGE

/ WITHOUT NOTICE AND SHOULD NOT BE CONSTRUED AS A COM-

/ MITMENT BY DIGITIAL EQUIPMENT CORPORATION.

/

/ DEC ASSUMES NO RESPONSIBILITY FOR THE USE OR RELIABILITY

/ OF ITS SOFTWARE ON EQUIPMENT WHICH IS NOT SUPPLIED BY DEC.

/

	.TITLE DESCRIPTION AND EDIT HISTORY

 

 

 

 

/

/ BDSLCT

/

/ THIS OVERLAY SELECTS THE NEXT JOB TO BE RUN.  UPON ENTRY,

/ THIS OVERLAY FIRST CHECKS THE EXJOB SWITCH TO DETERMINE

/ WHETHER BATCH SHOULD EXIT (EXJOB<0), PAUSE BETWEEN JOBS

/ (EXJOB>0), OR RUN JOBS (EXJOB=0).

/

/ IF EXJOB>0 OR IF EXJOB=0 AND NO JOBS CAN BE RUN, WE DELAY

/ A SHORT WHILE AND TRY AGAIN.  IF EXJOB=0 AND ONE OR MORE JOBS

/ CAN BE RUN, WE ASSIGN A PRIORITY TO EACH JOB USING SUBROUTINE

/ PRIORI.  THE HIGHEST PRIORITY JOB IS SELECTED FOR EXECUTION;

/ TIES GO TO THE JOB WHICH HAS BEEN WAITING THE LONGEST.  THE

/ SELECTED JOB NODE IS COPIED TO THE RESIDENT SECTION, THE NODE

/ IS RETURNED TO THE FREE POOL, AND JOBFND SET TO +1.  THEN

/ WE EXIT TO BDOPEN.

/

 

 

 

 

/

/ 100	20-AUG-76 (EAG)		INITIAL VERSION FOR MULTIACCESS

/				BATCH.  SUBROUTINE PRIORI IS

/				TAKEN FROM BAT.32 (NON-MULTI-

/				ACCESS BATCH).

/

	.TITLE MISCELLANEOUS ASSEMBLY CONSTANTS & MACROS

 

 

 

 

/

/ NOTE:  THIS PROGRAM USES NO ASSEMBLY PARAMETERS.  ALL

/	 PARAMETERIZED VALUES ARE OBTAINED FROM THE

/	 RESIDENT SECTION VIA INITIALIZATION CODE.

/

 

 

 

TDV=240426			/ .SIXBT "TDV".  USED TO

				/ CHECK FOR TDV PARTITIONS

				/ TO DETERMINE MAXIMUM TDV

				/ PARTITION SIZE.

 

MINSIZ=22000			/ MINIMUM TDV PARTITION SIZE

				/ REQUIRED TO RUN BATCH.  9K

				/ IS REQUIRED TO RUN JOB...

				/ AND END....  NOTE THAT IF

				/ THIS CONSTANT IS CHANGED,

				/ THE ERROR MESSAGE FOR BATCH

				/ SYSTEM ERROR # 201 MUST BE

				/ CHANGED IN BDABRT.

 

 

 

/

/ INDIRECT-INDEXED INSTRUCTION MNEMONICS:

/

 

LACIX=LAC* X

TADIX=TAD* X

 

 

 

/

/ DEFINE MACRO TO EXIT FROM TASK:

/

 

	.DEFIN EXIT

	  CAL (10)

	.ENDM

 

 

 

/

/ DEFINE DEBUGGING AID MACRO:

/

 

	.DEFIN .DEBUG MESSAG,WORD,FORM

	.ENDM

 

	.IFDEF %DEBUG

 

	.DEFIN .DEBUG MESSAG,WORD,FORM

	  .NOLST

	  .GLOBL .DBG

	  JMS* .DBG

	    .ASCII MESSAG@<0>

	    .DSA FORM

	    .DSA WORD

	  .LST

	.ENDM

 

	.ENDC

	.TITLE REFERENCES TO EXECUTIVE'S SCOM AREA

 

 

 

 

/

/ AUTO-INCREMENT REGISTERS:

/

 

X16=16

 

 

 

/

/ REENTRANT REGISTERS USED TO INTERFACE TO REENTRANT

/ ROUTINES:

/

 

R1=101

R2=102

 

 

 

/

/ REENTRANT SYSTEM ROUTINE ENTRY POINTS:

/

 

NADD=107			/ ADD NODE IN R2 TO

				/ LISTHEAD IN R1.

 

 

 

/

/ POINTER TO BATCH CONTROL VECTOR (VECTOR IS LOCATED IN

/ THE RESIDENT SECTION).  THIS POINTER MUST BE ZEROED PRIOR

/ TO TASK EXIT.

/

 

BATWD=147

 

 

 

/

/ TIME VALUES:

/

 

SSM=160				/ SECONDS SINCE MIDNIGHT.

 

MO=166				/ CURRENT MONTH (1 = JANUARY)



DA=167				/ CURRENT DAY (WITHIN MONTH)



YR=170				/ CURRENT YEAR (0 = 1900)

 

 

 

/

/ QUEUE LISTHEADS:

/

 

POOL=240			/ POOL OF EMPTY NODES.

 

PBDL=250			/ PARTITION DESCRIPTOR BLOCK

				/ LIST.

 

 

 

/

/ QUEUE LISTHEAD:

/

 

JOB1=323			/ BATCH JOB QUEUE.

 

 

 

/

/ REENTRANT SYSTEM ROUTINE ENTRY POINT:

/

 

NDELXR=444			/ DELETES NODE IN XR FROM

				/ WHATEVER QUEUE IT IS IN.

	.TITLE NODE FORMAT DEFINITIONS

 

 

 

 

/

/ REFERENCES TO PBDL NODES:

/

 

P.FP=0				/ FORWARD POINTER.

P.N1=2				/ FIRST WORD OF PARTITION NAME.

P.SZ=5				/ PARTITION SIZE IN WORDS.

 

 

 

/

/ REFERENCES TO JOB QUEUE NODES ARE CODED USING NUMERIC

/ CONSTANTS PLUS THE MASKS USED TO REFERENCE THE CURRENT

/ JOB NODE IMAGE.  FOR A DETAILED DESCRIPTION OF THE

/ JOB QUEUE NODE FORMAT, SEE THE RESIDENT SECTION.

/

	.TITLE REFERENCES TO BDRES AND OTHER BATCH OVERLAYS

 

 

 

 

/

/ DEFINE ENTRY POINT TO THIS OVERLAY:

/

 

	.GLOBL BDSLCT

 

 

 

/

/ DEFINE ENTRY POINT TO BATCH OVERLAY WHICH

/ THIS OVERLAY EXITS TO:

/

 

	.GLOBL BDOPEN

 

 

 

/

/ DEFINE ENTRY POINT TO BATCH SYSTEM ERROR PROCESSOR:

/

 

	.GLOBL BDABRT

 

 

 

/

/ DEFINE ENTRY POINTS TO ROUTINES IN RESIDENT SECTION:

/

 

	.GLOBL ISSUE		/ ROUTINE TO ISSUE CPB'S.

 

 

 

/

/ DEFINE REFERENCES TO CURRENT JOB NODE IMAGE (PRIMARY NODE):

/

 

	.GLOBL JBNAM1		/ FIRST WORD OF JOB NAME.

 

	.GLOBL JBNAM2		/ SECOND WORD OF JOB NAME.

 

	.GLOBL JBID		/ JOB ID OR SEQUENCE NUMBER.

 

	.GLOBL JBFLGS		/ JOB FLAGS WORD. (SEE BELOW)

 

	.GLOBL JBPARM		/ JOB PARAMETERS.  (SEE BELOW)

 

	.GLOBL JBDATE		/ DATE OF JOB SUBMITTAL.

 

	.GLOBL JBSSM		/ TIME (SSM) OF JOB SUBMITTAL.

 

 

 

/

/ DEFINE REFERENCES TO CURRENT JOB NODE IMAGE (SECONDARY NODE):

/

 

	.GLOBL INDVU		/ INPUT DEVICE AND UNIT.

 

	.GLOBL INUFD		/ INPUT UFD.

 

	.GLOBL LSTDVU		/ LISTING DEVICE AND UNIT.

 

	.GLOBL LSTUFD		/ LISTING UFD.

 

	.GLOBL LGNDVU		/ LOGIN DEVICE AND UNIT.

 

	.GLOBL LGNUFD		/ LOGIN UFD.

 

 

 

/

/ DEFINE BIT MASKS WITHIN JOB FLAGS WORD (JBFLGS):

/

 

OPRFLG=200000			/ OPERATOR REQUIRED TO RUN JOB.

 

FRCFLG=100000			/ JOB FORCED BY OPERATOR.

 

SEQFLG=040000			/ JOB SEQUENCING REQUIRED.

 

HLDFLG=010000			/ HOLD FOR OPERATOR RELEASE.

 

CCLFLG=004000			/ CCL PROCESSING REQUIRED.

 

TIMMSK=001777			/ TIME ESTIMATE.

 

 

 

/

/ DEFINE BIT MASKS WITHIN JOB PARAMETERS WORD (JBPARM):

/

 

CLSMSK=700000			/ JOB CLASS.

 

MEMMSK=000177			/ MEMORY REQUIREMENT.

 

 

 

/

/ DEFINE SCHEDULING PARAMETERS (LOCATED WITHIN BATCH

/ CONTROL VECTOR, SET BY OPR).

/

 

	.GLOBL WFACTR		/ WAIT TIME MULTIPLIER.

 

	.GLOBL TFACTR		/ TIME ESTIMATE MULTIPLIER.

 

	.GLOBL CFACTR		/ JOB CLASS MULTIPLIER.

 

	.GLOBL OPON		/ OPERATOR ON DUTY FLAG.

				/ 1 => OPERATOR ON

				/ 0 => OPERATOR OFF

 

	.GLOBL WAIMAX		/ MAXIMUM ALLOWABLE WAIT TIME.

 

	.GLOBL TIMMAX		/ MAXIMUM ALLOWABLE RUN TIME.

 

	.GLOBL CLSMIN		/ MINIMUM ALLOWABLE JOB CLASS.

 

	.GLOBL DEFTIM		/ DEFAULT JOB TIME LIMIT.

 

 

 

/

/ OTHER LOCATIONS IN BATCH CONTROL VECTOR:

/

 

	.GLOBL TIMLIM		/ CURRENT JOB FILE TIME LIMIT.

				/ NEGATIVE OF THE MAXIMUM

				/ SECONDS ALLOWED.

 

	.GLOBL JOBFND		/ JOB FOUND & EXECUTING FLAG.

				/ 0 => NO JOB BEING EXECUTED.

				/	(I.E., CURRENT JOB NODE

				/	IMAGE IS INVALID).

				/ 1 => JOB BEING EXECUTED,

				/	START-UP SEQUENCE OR

				/	END-OF-JOB SEQUENCE

				/	IN PROGRESS.

				/ 2 => JOB IS RUNNING.

				/ 3 => BATCH IS SCANNING TO

				/	$ERR CARD (JOB HAS

				/	BEEN KILLED).

 

	.GLOBL JOBERR		/ JOB ERROR FLAGS WORD.

 

	.GLOBL EXJOB		/ BATCH EXIT SWITCH.

				/ 0 => EXECUTE JOBS.

				/ +1 => PAUSE AT END OF JOB.

				/ -1 => EXIT AT END OF JOB.

 

 

 

/

/ REFERENCES TO OTHER WORDS IN RESIDENT:

/

 

	.GLOBL RUNTIM		/ LOCATION WHICH ACCUMULATES

				/ THE RUN TIME (SECONDS)

				/ (CLOCK OR REAL TIME MINUS

				/ PARTITION WAIT TIME) FOR

				/ ALL JOBS IN THE CURRENT

				/ JOB FILE.

 

	.GLOBL JOBNUM		/ LOCATION CONTAINING THE

				/ NUMBER OF THE CURRENT JOB

				/ WITHIN THE CURRENT JOB

				/ FILE.

	.TITLE BDSLCT MAIN ENTRY POINT, PAUSE & EXIT CHECK

 

 

 

 

/

/ MAIN ENTRY POINT TO BDSLCT.  OVERLAY CALLED VIA JMS, BUT

/ THE JMS WILL NEVER RETURN.

/

 

BDSLCT	0

	.DEBUG <"BDSLCT ENTERED, EXJOB = ">,EXJOB,31

/ COME HERE TO CHECK THE STATE OF EXJOB TO DETERMINE

/ WHETHER TO SELECT A JOB AND PROCESS IT (EXJOB=0),

/ PAUSE AND TRY AGAIN LATER (EXJOB>0), OR TERMINATE

/ BATCH PROCESSING (EXJOB<0).

GETJOB	DZM* JOBFND		/ CLEAR JOB IN PROGRESS

				/ FLAG (JUST IN CASE).

	LAC* EXJOB		/ FETCH BATCH EXIT/PAUSE FLAG

	SNA			/ SKIP IF PAUSE OR EXIT.

	JMP SELECT		/ JMP TO SELECT A JOB TO BE RUN

	SMA			/ SKIP IF EXIT.

	JMP NOJOBS		/ JMP TO PAUSE, THEN TRY AGAIN.

	DZM* (BATWD)		/ CLEAR LOCATION IN SCOM WHICH

				/ POINTS TO BATCH CONTROL VCTR

				/ (IN RESIDENT SECTION), SIN-

				/ DICATING THAT BATCH IS NO

				/ LONGER RUNNING.

	.DEBUG <"BDSLCT -- BATCH EXITTING.">,0,0

	EXIT			/ AND EXIT BATCH!

	.TITLE NOJOBS -- DELAY, THEN TRY AGAIN FOR A JOB

 

 

 

 

/

/ COME HERE WHEN BATCH IS IN PAUSE MODE (EXJOB>0) OR

/ WHENEVER THERE ARE NO JOBS TO PROCESS.  WAIT FIVE

/ SECONDS, THEN TRY AGAIN.

/

 

NOJOBS	JMS* ISSUE		/ ISSUE MARK CPB FOR

	  NOJB.A		/ FIVE SECONDS.

	CAL NOJB.B		/ WAITFOR IT TO FINISH.

	JMP GETJOB		/ GO CHECK FOR JOBS.

 

 

/ MARK CPB TO DELAY 5 SECONDS

 

NOJB.A	13

	NOJB.0

	5			/ INTERVAL = 5 SECONDS

	2			/ UNITS = SECONDS

 

 

/ WAITFOR CPB TO WAIT FOR MARK TO COMPLETE

 

NOJB.B	20

	NOJB.0

 

 

/ EVENT VARIABLE

 

NOJB.0	0

	.TITLE SELECT -- SELECT NEXT JOB TO RUN

 

 

 

 

/

/ COME HERE TO SCAN THE JOB QUEUE AND SELECT A JOB TO RUN.

/ FIRST WE SET UP LOCATIONS USED BY SUBROUTINE PRIORI, THEN

/ WE SCAN THE JOB QUEUE.

/

 

SELECT	LAW -1			/ SET SEQCNT TO -1, SO THAT

	DAC SEQCNT		/ ONLY FIRST JOB WITH SEQ FLAG

				/ CAN RUN.

/ SET UP LOCATION TDV SIZE TO SIZE (IN 1K UNITS) OF LARGEST

/ TDV PARTITION.

	DZM TDVSIZ		/ SET ZERO => SMALLEST VALUE.

	LAC* (PBDL)		/ PREPARE TO SCAN PBDL.

SLJB.A	SAD (PBDL)		/ REACHED END?

	JMP SLJB.C		/ JMP IF YES -- TDVSIZ SET UP.

	PAX

	LACIX (P.N1)		/ FETCH FIRST PART. NAME WORD.

	SAD (TDV)		/ IS IT TDV PARTITION?

	SKP!CLL			/ SKIP IF TDV PARTITION.

	JMP SLJB.B		/ JMP IF NOT -- TRY NEXT PART.

	LACIX (P.SZ)		/ EXTRACT PARTITION SIZE AND

	LRS+12			/ CONVERT TO 1K UNITS.

	CLL!TCA			/ COMPARE SIZE WITH LARGEST

	TAD TDVSIZ		/ SEEN SO FAR.

	SMA!TCA			/ SKIP IF NEW ONE LARGER.

	JMP SLJB.B		/ JMP IF OLD ONE LARGER -- TRY

				/ NEXT PARTITION.

	TAD TDVSIZ		/ GET BACK SIZE OF NEW PART.

	DAC TDVSIZ		/ AND UPDATE LARGEST SIZE SEEN.

SLJB.B	LACIX (P.FP)		/ SCAN TO NEXT ENTRY IN PBDL.

	JMP SLJB.A		/ AND GO CHECK IT OUT.

 

 

/ COME HERE AFTER PBDL SCAN FINISHES.  VERIFY TDVSIZ

/ IS LARGER THAN MINSIZ, WHICH IS REQUIRED FOR BATCH TO

/ RUN.  THEN SET UP LOCATIONS NOW (TO CURRENT SSM VALUE)

/ AND TODAY (TO CURRENT DATE, IN SAME FORMAT AS USED IN

/ JOB QUEUE NODES).

 

SLJB.C	LAC (MINSIZ+1777)	/ CONVERT MINSIZ FROM WORDS

	LRSS+12			/ TO 1K UNITS, ROUNDING UP.

	CLL!TCA			/ COMPARE WITH TDVSIZ.

	TAD TDVSIZ		/ SET LINK IF TDVSIZ SAME OR

				/ BIGGER, CLEAR LINK IF

				/ TDVSIZ SMALLER.

	LAW -201		/ ASSUME TDVSIZ SMALLER.

	SNL			/ SKIP IF TDVSIZ BIG ENOUGH.

	JMS* BDABRT		/ JMS IF TDVSIZ SMALLER THAN

				/ MINSIZ -- BATCH SYSTEM ERROR.

/

	LAC* (DA)		/ SAVE DATE IN TEMPORARY.

	DAC SLJB.0

	LAC* (YR)		/ FORMAT DATE -- 9 BITS

	CLL!RTL			/ OF YEAR, 4 BITS OF MONTH,

	RTL			/ AND 5 BITS OF DAY.

	XOR* (MO)

	RTL

	RTL

	RAL

	XOR* (DA)

	DAC TODAY		/ SAVE FORMATTED DATE.

	LAC* (SSM)		/ SAVE TIME (SSM) IN LOCATION

	DAC NOW			/ NOW.

	LAC* (DA)		/ HAS DATE CHANGED WHILE WE

	SAD SLJB.0		/ WERE SAVING DATE/TIME?

	SKP!CLA!CMA		/ SKIP IF IT DIDN'T.

	JMP SLJB.C		/ JMP IF TIME CHANGED --

				/ MUST GO BACK AND TRY AGAIN

				/ TO ENSURE CONSISTENT #'S.

/ COME HERE AFTER LOCATIONS NOW AND TODAY ARE SET CONSISTENTLY.

/ SET UP LOCATION YSTRDAY BY BACKING UP TODAY BY ONE DAY.

/ NOTE THAT THE AC CONTAINS -1 WHEN WE GET HERE.

	TAD TODAY		/ DECREMENT DAY FIELD.

	DAC YSTRDAY

	AND (37)		/ MASK OUT DAY FIELD.

	SZA			/ DID WE DECREMENT TO ZERO?

	JMP SLJB.F		/ JMP OF NO -- DONE W/ YSTRDAY.

	LAW -40			/ DAY WENT TO ZERO -- DECREMENT

	TAD YSTRDAY		/ THE MONTH.

	DAC YSTRDAY

	AND (17*40)		/ MASK OUT MONTH FIELD.  DID

	SZA			/ WE DECREMENT IT TO ZERO?

	JMP SLJB.D		/ JMP IF NO -- GO SET UP DAYS.

	LAW 14*40-1000		/ DECREMENT YEAR, AND SET

	TAD YSTRDAY		/ MONTH TO 14 OCTAL = 12 DEC.

	DAC YSTRDAY		/ = DECEMBER.

SLJB.D	AND (15*40)		/ MASK MONTH FIELD WITH MAGIC

				/ CONSTANT.

	SZA			/ SKIP IF FEBRUARY.

	JMP SLJB.E		/ JMP IF NOT FEBRUARY.

	LAC YSTRDAY		/ CHECK LOW TWO BITS OF YEAR,

	SWHA			/ TO CHECK FOR LEAP YEAR.

	RTR			/ LOW BITS IN LINK & AC SIGN.

	SNL!SMA!CLA		/ SKIP IF NOT LEAP YEAR.

	LAW -1			/ LOAD AC WITH MINUS NUMBER

	AAC -34			/ OF DAYS IN FEBRUARY.

SLJB.E	SAD (4*40)		/ CHECK IF APRIL OR JUNE.

	LAW -36			/ LOAD AC WITH -30 DAYS.

	SAD (11*40)		/ CHECK IF SEPT. OR NOV.

	LAW -36			/ LOAD AC WITH -30 DAYS.

	SMA!TCA			/ SKIP IF NOT 31 DAY MONTH.

	LAC (37)		/ LOAD AC WITH 31 DAYS.

	TAD YSTRDAY		/ MERGE UPDATED DAYS FIELD

	DAC YSTRDAY		/ INTO YSTRDAY'S DATE.

/ COME HERE AFTER YSTRDAY PROPERLY SET UP.

SLJB.F	JMP SCAN		/ GO SCAN THE JOB QUEUE!

 

 

 

SLJB.0	0			/ TEMPORARY USED ABOVE.

	.TITLE SCAN -- SCAN THE JOB QUEUE

 

 

 

 

/

/ COME HERE TO SCAN THE JOB QUEUE FOR THE HIGHEST PRIORITY

/ JOB.  WHEN THE HIGHEST PRIORITY JOB IS DETERMINED, GO TO

/ FOUND WITH IT'S JOB QUEUE NODE ADDRESS IN THE XR.  IF

/ NO JOB IS FOUND TO RUN, GO TO NOJOBS.

/

/ NOTE THAT THE JOB QUEUE IS SCANNED IN REVERSE ORDER,

/ SO THAT JOBS WILL BE SCANNED IN THE SAME ORDER THEY

/ WERE SUBMITTED.  THIS IS NECESSARY TO MAKE JOB

/ SEQUENCING TESTS WORK CORRECTLY AND TO ENSURE THAT

/ OLDER JOBS ARE GIVEN PREFERENCE OVER NEWER JOBS.

/

/ NOTE THAT SUBROUTINE PRIORI ACCEPTS A JOB QUEUE NODE

/ ADDRESS IN THE XR.  IT PRESERVES THE XR AND RETURNS

/ THE JOB'S PRIORITY IN THE AC.  PRIORITIES RANGE FROM

/ 0 - 400000.  ZERO INDICATES THE JOB IS INELIGIBLE TO

/ RUN.  400000 INDICATES THAT THE JOB HAS BEEN OPERATOR

/ FORCED, AND SHOULD BE RUN IMMEDIATELY WITHOUT SCANNING

/ THE REST OF THE JOB QUEUE.  400000 ALSO IS USED WHEN

/ A JOB HAS BEEN CANCELLED, SO THAT THE CANCELLED JOB'S

/ JOB QUEUE NODE WILL BE PROMPTLY FREED.  ALL OTHER

/ PRIORITIES ARE "REAL" PRIORITIES.

/

 

SCAN	DZM BSTND		/ ZERO ADDRESS OF BEST JOB

				/ FOUND SO FAR.

	DZM BSTPRI		/ AND SET BEST PRIORITY TO

				/ THE MINIMUM.

	CLX			/ SET UP XR TO SCAN JOB

	AXR JOB1		/ QUEUE.

SCAN.A	LACIX (1)		/ FETCH NEXT JOB QUEUE NODE

	SAD (JOB1)		/ REACHED END OF JOB QUEUE?

	JMP SCAN.B		/ JMP IF YES.

	PAX			/ NO -- POINT XR TO NODE.

	JMS PRIORI		/ GET ITS PRIORITY.

	SPA!CLL!TCA		/ SKIP IF NOT OPER. FORCED.

	JMP SCAN.C		/ JMP IF OPERATOR FORCED.

	TAD BSTPRI		/ COMPARE PRI. W/ BEST SO FAR.

	SMA!TCA			/ SKIP IF NEW ONE BETTER.

	JMP SCAN.A		/ JMP IF OLD ONE BETTER -- TRY

				/ NEXT JOB IN THE QUEUE.

	TAD BSTPRI		/ GET BACK NEW PRIORITY.

	DAC BSTPRI		/ UPDATE BEST PRI. SO FAR.

	PXA			/ AND REMEMBER THIS NODE

	DAC BSTND		/ ADDRESS.

	JMP SCAN.A		/ TRY NEXT JOB QUEUE NODE.

 

 

/ COME HERE WHEN SCAN REACHES END OF JOB QUEUE.

 

SCAN.B	LAC BSTND		/ CHECK IF A NODE WAS FOUND.

	SNA			/ SKIP IF IT WAS.

	JMP NOJOBS		/ JMP IF ONE WASN'T.

	PAX			/ POINT XR TO JOB NODE.

/ COME HERE WITH JOB QUEUE NODE ADDRESS IN XR.

SCAN.C	.DEBUG <"BDSLCT:SCAN -- JOB NODE CHOSEN:  ">,-2,20

	JMP FOUND		/ GO PROCESS JOB.

 

 

 

BSTPRI	0			/ HIGHEST PRIORITY SEEN

				/ SO FAR.

 

BSTND	0			/ ADDRESS OF HIGHEST PRIORITY

				/ JOB QUEUE NODE SEEN SO FAR.

	.TITLE FOUND -- EXTRACT DATA FROM JOB QUEUE NODE

 

 

 

 

/

/ COME HERE WITH JOB QUEUE NODE ADDRESS OF JOB TO BE RUN

/ IN THE XR.  THIS ROUTINE COPIES THE JOB QUEUE NODE TO

/ THE IMAGE OF IT IN THE RESIDENT SECTION, SETS THE JOBFND

/ FLAG IN THE RESIDENT SECTION TO INDICATE THAT A JOB IS

/ BEING PROCESSED, DELETES THE NODE FROM THE JOB QUEUE,

/ AND RETURNS THE NODES TO THE FREE POOL.

/

 

FOUND	LACIX (2)		/ COPY JOB FILE NAME TO

	DAC* JBNAM1		/ RESIDENT IMAGE.

	LACIX (3)

	DAC* JBNAM2

	.DEBUG <<11><11>"JOB NAME:"<11>>,JBNAM1,71

	LAW -1			/ SET UP X16 TO FETCH FROM

	TADIX (4)		/ THE SECONDARY NODE.

	DAC* (X16)

	LACIX (5)		/ COPY JOB ID TO RES. IMAGE.

	DAC* JBID

	.DEBUG <<11><11>"JOB ID:"<11><11>>,JBID,41

	LACIX (6)		/ COPY JOB FLAGS WORD.

	DAC* JBFLGS

	.DEBUG <<11><11>"JOB FLAGS:"<11>>,JBFLGS,21

	LACIX (7)		/ COPY JOB PARAMETER WORD.

	DAC* JBPARM

	.DEBUG <<11><11>"PARAMETERS:"<11>>,JBPARM,21

	LACIX (10)		/ COPY JOB SUBMITTAL DATE.

	DAC* JBDATE

	.DEBUG <<11><11>"JOB DATE:"<11>>,JBDATE,21

	LACIX (11)		/ COPY JOB SUBMITTAL TIME (SSM)

	DAC* JBSSM

	.DEBUG <<11><11>"JOB SSM:"<11>>,JBSSM,41

	LAC* X16		/ COPY JOB FILE INPUT DEVICE,

	DAC* INDVU		/ UNIT, AND UFD FROM SECONDARY

	.DEBUG <<11>"SECONDARY NODE ADDRESS:  ">,X16,20

	LAC* X16		/ NODE TO RESIDENT IMAGE.

	DAC* INUFD

	.DEBUG <<11><11>"INPUT DEVICE:"<11>>,INDVU,101

	LAC* X16		/ COPY LISTING OUTPUT DEVICE,

	DAC* LSTDVU		/ UNIT, AND UFD.

	LAC* X16

	DAC* LSTUFD

	.DEBUG <<11><11>"LISTING DEVICE:"<11>>,LSTDVU,101

	LAC* X16		/ COPY LOGIN DEVICE, UNIT,

	DAC* LGNDVU		/ AND UFD.

	LAC* X16

	DAC* LGNUFD

	.DEBUG <<11><11>"LOGIN DEVICE:"<11>>,LGNDVU,101

	DZM* JOBERR		/ CLEAR JOB ERROR FLAGS.

	DZM* RUNTIM		/ ZERO JOB FILE RUN TIME.

	DZM* JOBNUM		/ ZERO JOB NUMBER WITHIN

				/ JOB FILE.

	LAC* JBFLGS		/ SET INITIAL VALUE OF TIMLIM

	AND (TIMMSK)		/ (TIME LIMIT) TO VALUE FROM

	SNA			/ JOB QUEUE NODE OR TO DEFAULT,

	LAC* DEFTIM		/ WHICHEVER IS APPROPRIATE.

	LMQ!CLAC!MUL		/ CONVERT POSITIVE MINUTES TO

	  74			/ NEGATIVE SECONDS.

	LACQ

	TCA

	DAC* TIMLIM

	LAC* JBID		/ CHECK IF JOB HAS BEEN

	SZA			/ CANCELLED.  SKIP IF IT HAS.

	ISZ* JOBFND		/ JOB NOT CANCELLED -- SET FLAG

				/ TO INDICATE JOB BEING

				/ PROCESSED.

	.DEBUG <"BDSLCT:FOUND -- JOBFND SET TO ">,JOBFND,11

	PXA			/ SET R2 TO PRIMARY NODE

	DAC* (R2)		/ ADDRESS FOR CALL TO NADD.

	JMS* (NDELXR)		/ DELETE PRIMARY NODE FROM

	LAC (POOL)		/ JOB QUEUE, THEN ADD TO

	DAC* (R1)		/ FREE NODE POOL.

	JMS* (NADD)

	LAC* (X16)		/ FETCH SECONDARY NODE ADDRESS,

	AAC -5			/ AND RETURN IT TO NODE POOL

	DAC* (R2)		/ ALSO.

	JMS* (NADD)

	JMS* BDOPEN		/ CALL NEXT OVERLAY.

	.TITLE LOCATIONS USED BY PRIORI

 

 

 

 

/

/ THE FOLLOWING LOCATIONS MUST BE INITIALIZED BEFORE

/ THE FIRST CALL TO PRIORI, AND LEFT UNMODIFIED

/ BETWEEN CALLS.

/

 

SEQCNT	-1			/ SET TO -1.

 

NOW	0			/ SET TO CURRENT TIME

				/ (SCOM LOCATION SSM).

 

TODAY	0			/ SET TO TODAY'S DATE IN

				/ FORMAT USED IN JOB QUEUE

				/ NODES.

 

YSTRDAY	0			/ SET TO YESTERDAY'S DATE

				/ IN FORMAT USED IN JOB

				/ QUEUE NODES.

 

TDVSIZ	0			/ SET TO SIZE, IN 1K UNITS,

				/ OF LARGEST TDV PARTITION.

 

 

 

/

/ THE FOLLOWING LOCATION IS A TEMPORARY USED BY PRIORI.

/

 

TEMP	0

 

 

 

/

/ LOCATIONS WAITM, TIMLM, AND CLSLM ARE ALSO USED AS

/ TEMPORARIES WITHIN PRIORI.  THEY ARE WITHIN PRIORI

/ ITSELF AS PART OF EAE MUL INSTRUCTIONS.

/

	.TITLE PRIORI -- SUBR. TO CALCULATE JOB PRIORITY

 

 

 

 

/

/ CALLED WITH JOB QUEUE NODE ADDRESS IN XR.  PRESERVES

/ XR, RETURNS JOB PRIORITY IN AC.  PRIORITIES RANGE

/ 0 - 400000.  ZERO IMPLIES JOB IS INELIGIBLE TO RUN,

/ 400000 IMPLIES JOB HAS BEEN FORCED BY OPERATOR OR THAT

/ JOB HAS BEEN CANCELLED.  THIS SUBROUTINE LARGELY COPIED

/ FROM NON-MULTIACCESS BATCH, BAT.32 SRC.

/

/ CALLING SEQUENCE:

/	< LOAD XR WITH JOB QUEUE NODE ADDRESS >

/	JMS PRIORI

/

/ REGISTERS ALTERED:

/	ALL EXCEPT XR

/

/ VALUES RETURNED:

/	AC = PRIORITY

/

 

PRIORI	0

 

	.DEBUG <"BDSLCT:PRIORI -- EVALUATING JOB NODE ">,-2,20

 

	LACIX (5)		/ CHECK JOB ID VALUE TO SEE IF

	SNA			/ JOB HAS BEEN CANCELLED.

	JMP FORCE		/ JMP IF JOB CANCELLED.

 

/ COMPUTE JOB WAITING TIME

 

	LACIX (10)		/ EXTRACT DATE OF SUBMITTAL

	SAD YSTRDAY		/ WAS IT YESTERDAY?

	JMP ONEDAY		/ YES -- ADJUST WAITING TIME

				/ BY ONE DAY.

	SAD TODAY		/ IS IT TODAY?

	JMP ZRODAY		/ YES -- DON'T ADJST WAITING TM

	JMP MORDAY		/ NO -- JOB SUBMITTED AT LEAST

				/ TWO DAYS AGO -- USE ONE

				/ DAY AS WAITING TIME.

 

 

/ COMPUTE WAITING TIME IN SECONDS MINUS ONE DAY.  NOTE THAT

/ 250600 IS THE NUMBER OF SECONDS PER DAY IN OCTAL.

 

ONEDAY	CLA!SKP			/ YESTERDAY -- DON'T SUBTRACT

				/ ONE DAY.

ZRODAY	LAC (250600)		/ TODAY -- SUBTRACT ONE DAY.

	TADIX (11)		/ ADJUST JOB SUBMITTAL TIME.

	TCA			/ AND SUBTRACT FROM CURRENT

	TAD NOW			/ TIME.

/ HAVE WAITING TIME MINUS ONE DAY.  ADD ONE DAY, AND RANGE

/ CHECK WAITING TIME -- IF > ONE DAY, USE ONE DAY.

	CLL			/ USE LINK FOR OVERFLOW CHECK.

	TAD (250600)		/ SET LINK IF TIME < 1 DAY.

	SNL!CLL			/ SKIP IF TIME < ONE DAY.

MORDAY	LAC (250600)		/ WAITING TIME > ONE DAY --

				/ USE ONE DAY INSTEAD.

	.DEBUG <<11>"WAITING TIME (SECONDS):  ">,-1,40

	CLL			/ HAVE WAITING TIME IN SECONDS

	IDIV			/ DIVIDE TO GET TIME IN MINUTES

	  74

	LACQ

	DAC WAITM		/ SAVE FOR LATER.

 

/ COMPUTE THE JOB TIME LIMIT IN A CODED FORM

/ THIS IS 01-LOG(2) TIMELIMIT

/ RESULT IS A NUMBER FROM 0 TO 9

/ 9 IS SHORT JOB -- 1 MINUTE

/ 0 IS LONG JOB -- 512 MINUTES OR LONGER

/ THIS FORMAT IS CHOSEN SO THAT SMALL TIMES GAIN

/ APPRECIABLE PRIORITY OVER LONG ONES.

 

	LACIX (6)		/ FETCH JOB FLAGS WORD

	AND (TIMMSK)		/ MASK OUT TIME LIMIT.

	SNA			/ IF ZERO, USE DEFAULT

	LAC* DEFTIM		/ TIME LIMIT.

	NORM			/ NORMALIZE THE TIME.

	LACS			/ BRING STEP COUNT TO AC.

	AAC -43			/ MAKE BIT 10 WORTH 0.

	.DEBUG <<11>"LOG(2) OF TIME LIMIT:  ">,-1,40

	DAC TIMLM		/ THIS IS THE COMPUTED

				/ TIME LIMIT.

 

/ TEST FOR JOB SEQUENCING.  LOCATION SEQCNT IS SET TO

/ -1 BEFORE THE JOB QUEUE IS SCANNED.  AN ISZ OF IT WILL

/ ALLOW THE FIRST JOB WITH THE SEQ FLAG TO RUN, BUT NOT

/ ANY LATER ONES.

 

	LACIX (6)		/ FETCH JOB FLAGS WORD.

	AND (SEQFLG)		/ CHECK FOR JOB SEQUENCING.

	SNA			/ SKIP IF FLAG SET.

	JMP HLDTST		/ JMP IF FLAG CLEAR.

	ISZ SEQCNT		/ FIRST JOB W/ SEQ FLAG?

	JMP NORUN		/ NO -- CAN'T RUN.

 

/ MAKE TESTS FOR HOLDING, OPERATOR, AND MEMORY SIZE.

 

HLDTST	LACIX (6)		/ FETCH JOB FLAGS WORD.

	AND (HLDFLG!CCLFLG)	/ CHECK FOR HLD OR CCL.

	SZA

	JMP NORUN		/ SORRY, ONE IS SET.

 

OPRTST	LACIX (6)		/ FETCH JOB FLAGS WORD.

	AND (OPRFLG)		/ IS OPERATOR REQUIRED?

	TAD* OPON		/ IS HE HERE?

	SAD (OPRFLG)		/ IF NEEDED, BUT NOT HERE,

	JMP NORUN		/ CANNOT RUN THE JOB.

 

MEMTST	LACIX (7)		/ FETCH JOB PARAMETERS WORD.

	AND (MEMMSK)		/ EXTRACT MEMORY SIZE.

	CMA			/ GET -SIZE NEEDED IN K

	TAD TDVSIZ		/ ADD SIZE AVAIL. IN K

	SPA			/ SKIP IF OK (GT OR EQ)

	JMP NORUN

 

/ TEST FOR JOB FORCING, TIME LIMIT TOO LONG, CLASS TOO

/ LOW, OR WAIT TOO LONG.

 

FORTST	LACIX (6)		/ FETCH JOB FLAGS WORD.

	AND (FRCFLG)		/ EXTRACT FORCE FLAG.

	SZA

	JMP FORCE		/ MUST RUN NOW!

 

TIMTST	LACIX (6)		/ FETCH JOB FLAGS WORD.

	AND (TIMMSK)		/ EXTRACT TIME ESTIMATE.

	SNA			/ IF ZERO, USE DEFAULT

	LAC* DEFTIM		/ TIME LIMIT.

	TCA

	TAD* TIMMAX		/ COMPARE WITH MAX. ALLOWED.

	SPA			/ ALLOWED IF SKIPPING.

	JMP NORUN

 

CLSTST	LACIX (7)		/ FETCH JOB PARAMETER WORD.

	AND (CLSMSK)		/ EXTRACT JOB CLASS.

	CLL!RTL			/ ROTATE IT AROUND THE END.

	RTL

	DAC CLSLM		/ SAVE FOR PRIORITY CALCU-

	TCA			/ LATION.

	TAD* CLSMIN		/ MUST BE ABOVE MIN.

	SMA!SZA			/ SKIP IF ALLOWED.

	JMP NORUN 

 

WAITST	LAC WAITM		/ WAITING TIME

	TCA

	TAD* WAIMAX

	SPA

	JMP RUNOW		/ RUN NOW IF WAIT GTR MAX



/ COMPUTE THE PRIORITY FOR THIS JOB

 

CMPRI	LAC* WFACTR		/ TEMP <-- WFACTR *

	CLL			/		WAITM / 2**18

	MUL

WAITM	  0

	DAC TEMP

 

	LAC* TFACTR		/ TEMP <-- TEMP + TFACTR *

	MUL			/		TIMLM

TIMLM	  0

	SZA!CLL			/ IF OVERFLOW, RETURN MAX.

	JMP RUNOW		/ VALUE.

	LACQ

	TAD TEMP

	SZL!SPA!CLL		/ IF OVERFLOW, RETURN MAX.

	JMP RUNOW		/ VALUE.

	DAC TEMP

 

	LAC* CFACTR		/ AC <-- TEMP + CFACTR *

	MUL			/		CLSLM

CLSLM	  0

	SZA!CLL			/ IF OVERFLOW, RETURN MAX.

	JMP RUNOW		/ VALUE.

	LACQ

	TAD TEMP

	SZL!SPA!CLL		/ IF OVERFLOW, RETURN MAX.

	JMP RUNOW		/ VALUE.

 

/ JOB HAS SURVIVED, RETURN PRIORITY TO CALLER.

 

	SNA			/ IF PRIORITY IS ZERO,

	CLA!IAC			/ RETURN +1 (MINIMUM PRIORITY

				/ FOR A JOB WHICH IS RUNNABLE).

	.DEBUG <<11><11>"PRIORITY=">,-1,20

	JMP* PRIORI

 

 

/ COME HERE IF JOB CAN'T BE RUN.

 

NORUN	CLA			/ RETURN ZERO.

	.DEBUG <<11>"JOB CAN'T BE RUN.">,0,0

	JMP* PRIORI

 

 

/ COME HERE IF JOB CAN BE RUN AND HAS OPERATOR FORCE SET,

/ OR IF JOB HAS BEEN CANCELLED (JOBID SET TO ZERO).

 

FORCE	LAC (400000)		/ RETURN NEGATIVE PRIORITY.

	.DEBUG <<11>"JOB FORCED.">,0,0

	JMP* PRIORI

 

 

/ COME HERE IF JOB CAN BE RUN AND PRIORITY OVERFLOWS, OR

/ WAITING TIME IS GREATER THAN MAXIMUM WAIT TIME.

 

RUNOW	LAC (377777)		/ RETURN MAXIMUM PRIORITY.

	.DEBUG <<11><11>"PRIORITY=">,-1,20

	JMP* PRIORI

 

 

 

 

	.END
