	.TITLE *** PARTITION WAITING ROUTINE ***
/
/ 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 PROVIDED 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 COMMITMENT BY DIGITAL EQUIPMENT
/ CORPORATION.
/
/ DEC ASSUMES NO RESPONSIBILITY FOR THE USE OR RELIABILITY OF ITS
/ SOFTWARE ON EQUIPMENT WHICH IS NOT SUPPLIED BY DEC.
/
	.TITLE *** EDIT LEGEND ***
	.TITLE *** MACROS USED BY PARTITION WAIT ***
/
/ MACRO TO DEFINE OFFSETS INTO THE USER CONTEXT AREA.
/
	.DEFIN UCAOFF
U.JSW=0				/OFFSET TO JOB STATUS WORD.
U.MAEV=1			/OFFSET TO EVENT VARIABLE
U.MAMTE=2			/OFFSET TO MARK TIME EVENT VARIABLE.
U.OEV=3				/OFFSET TO OVERLAY EVENT VARIABLE.
U.DSK=4				/OFFSET TO DISK NAME
U.DUN=5				/OFFSET TO DISK UNIT NUMBER
U.UFD=6				/OFFSET TO UFD NAME.
U.CTSK=7			/OFFSET TO CURRENT TASK NAME
U.PSC=11			/OFFSET TO PARTITION SELECTION CRITERIA.
U.ULOF=14			/OFFSET TO USER NUMBER AND LUN OFFSET.
U.TTYN=15			/OFFSET TO USER TERMINAL NUMBER.
U.TB=16				/OFFSET TO USER TERMINAL BUFFER.
U.CPB=62			/OFFSET TO MULTI-ACCESS CPB.
U.SSM=74			/SECONDS SINCE MIDNIGHT INTO STATE 11
				/ OR 12 (HUNG ON PARTITION)
U.TW=75				/TOTAL TIME IN SECONDS SPENT IN STATE 11
				/ OR 12.
U.OVID=76			/OVERLAY IDENTIFIER (LAST OVERLAY CALLED)
U.CKS=77			/CHECKSUM OF INPUT BUFFER FOR TIMED READ.
U.LEN=100			/LENGTH OF UCA.
	.DEFIN UCAOFF
	.ENDM
	.ENDM
/
/ MACRO WHICH DEFINES SYSTEM TASK LIST ENTRIES
/ THIS ALSO DEFINES ALL BITS FOR EACH FLAG WORD.
/
	.DEFIN STLOFF
S.FP=0			/FORWARD LINKAGE.
S.BP=1				/BACKWARD LINKAGE.
S.N1=2				/TASK NAME
S.N2=3				/TASK NAME
S.DP=4				/FLAGS AND DEFAULT PRIORITY.
S.PB=5				/PARTITION BLOCK ADDRESS
S.DA=6				/DISK ADDRESS AND UNIT.
S.DB=7				/RESIDENT CODE LENGTH (DISK TRANSFER)
S.TS=10				/TASK SIZE.
S.EP=11				/TASK ENTRY POINT.
/
/ DEFINE S.DP BIT EXTRACTION MASKS.
/
S.ETA=400000			/EXTRACT TASK ACTIVE
S.EROX=200000			/EXTRACT REMOVE ON EXIT.
S.ETDI=100000			/EXTRACT TASK DISABLED.
S.EFIX=40000			/EXTRACT TASK FIXED IN CORE.
S.EPLC=20000			/EXTRACT PARTITION LOST IN RECONFIG.
S.ERCP=10000			/EXTRACT RECONFIGURATION IN PROGRESS.
S.ETEX=4000			/EXTRACT TASK HAS EXITTED.
S.EDP=1777			/EXTRACT DEFAULT PRIORITY.
/
/ DEFINE S.TS BIT EXTRACTION MASKS.
/
S.ETS=777400			/EXTRACT TASK SIZE.
S.ERD=200			/EXTRACT RELOCATE DISABLE.
S.EXM=140			/EXTRACT XVM MODE.
S.EIOT=20			/EXTRACT IOT PERMISSION.
/
/ DEFINE S.EP BIT EXTRACTION MASKS.
/
S.ELC=400000			/EXTRACT LINK CONTENTS.
S.EPB=200000			/EXTRACT PAGE/BANK INDICATOR.
S.EEN=100000			/EXTRACT EXEC/NORMAL MODE.
S.EEP=77777			/EXTRACT ENTRY POINT ADDRESS.
	.DEFIN STLOFF
	.ENDM
	.ENDM
 
	.TITLE *** DIRECT ASSEMBLY TIME ASSIGNMENTS ***
 
NADD=107		/ POIJTER TO NODE ADD ROUTINE IN EXEC.	
NDEL=112		/ POINTER TO NODE DELETE ROUTINE IN EXEC
POOL=240		/ POINTER TO FREE LIST IN EXEC.		
	UCAOFF		/ DEFINE THE OFFSETS TO THE UCA WORDS.
	STLOFF		/ DEFINE STL OFFSETS.			
R1=101			/ REENTRENT REGITSTER 1.		
R2=102			/ REENTRANT REGISTER 2.			
SNAM=123		/ ENTRY TO SCAN LIST FOR NAME.		
X10=10			/ POINTER TO AUTOINCREMENT REGISTER 10.
X11=11			/ SAME FOR AR 11.			
.INH=705522
.ENB=705521
ECLA=641000		/ EAE CLEAR THE AC.			
CALX=10000		/ CAL INDEXED.				
IDX=ISZ			/ NON SKIPPING ISZ.			
	.TITLE *** MACRO'S FOR PARTITION FITTING ROUTINE ***
 
	.DEFIN TEXT,STR
P.ERC=0
	.DEFIN TEXT,A,?B
P.ERC=P.ERC-1
	B-.*400&777000+2
	P.ERC
	.ASCII :A:<15>
B=.
	.ENDM
	TEXT <STR>
	.ENDM
	.TITLE *** EQUATES FOR PARTITION FITTING ROUTINE ***
 
P.TDV=240426
P.NAME=2
P.MINS=1
P.N1=2
P.N2=3
P.SZ=5
P.FW=10
P.TC=47
X10=10
P.PBDL=250
RPL=705512
P.ERIP=4
P.LVL5=400004
	.TITLE *** VARIABLES AND STORAGE FOR PARTITION FITTING ***
 
/ INTERNAL GLOBAL SYMBOLS
 
	.GLOBL PWAIT
 
/ EXTERNAL GLOBAL SYMBOLS
 
	.GLOBL TS.CTR
	.GLOBL TDVTYP
 
XRADJ	0
UCAADR	0
TTYN	0
P.POOL	.BLOCK 2*22	/ 18 (10) MAXIMUM PARTITONS ASSUMED.
P.TMP1	0
P.TMP2	0
P.TMP3	0
P.TMP4	0
P.TSKS	0		/ SIZE TO BE SCANNED FOR.
P.STL	0
 
P.ER20	TEXT <CAN'T RUN -- TASK DISABLED>
P.ER50	TEXT <CAN'T RUN -- PARTITION IS TOO SMALL>
P.ER60	TEXT <CAN'T RUN -- PARTITION IS NO LONGER IN SYSTEM>
P.ER70	TEXT <CAN'T RUN -- NO PARTITION IS BIG ENOUGH FOR TASK>
	.TITLE *** PARTITION WAIT MAIN CODE ***
 
PWAIT	XX		/ ENTRY POINT.
	DAC UCAADR	/ SAVE UCA ADDRESS.
	LAC (.)		/ CALCULATE XR ADJUSTMENT.
	AND (70000)
	CMA!IAC		/ MAKE FUDGE FACTOR NEGATIVE.
	DAC XRADJ	/ STORE XR ADJUSTMENT.
/
	LAC UCAADR	/ FETCH TTYN FROM UCA.
	JMS SETXR	/ SET UP INDEXING.
	LAC U.TTYN,X	/ FETCH TTY NUMBER FROM UCA.
	DAC TTYN	/ FOR PRINT ROUTINES.
	LAC U.CPB,X	/ FETCH STL NODE ADDRESS FROM UCA.
	DAC P.STL
	JMS P.FIT	/ FIT THE PROPER STL NODE ADDRESS INTO
			/ A PARTITION.
	JMP* PWAIT	/ TAKE NORMAL RETURN TO CODE.
	ISZ PWAIT	/ SET UP TO TAKE ERROR RETURN.
	JMP* PWAIT	/ TAKE ERROR RETURN.
	.TITLE *** PARTITION FITTING ROUTINE ***
 
/ THIS ROUTINE IS CALLED IN ORDER TO FIND A PARTITION FOR A MULTIACCESS
/ JOB TO RUN IN. THE PARTITION FIT ROUTINE HAS TWO INPUT ARGUMENTS:
/
/ 1. THE ADDRESS OF THE UCA.
/ 2. THE ADDRESS OF THE ALIAS STL NODE WITH THE INFORMATION (INCLUDING
/    THE PARTITION NAME) WHICH WAS COPIED FROM THE ORIGIONAL STL NODE.
/
/ THE CALLING FORMAT IS AS FOLLOWS:
/
/	JMS P.FIT
/	LAC STLADR
/	...			/ ERROR FREE RETURN.
/				/ THE ERROR FREE RETURN WILL ALWAYS BE
/				/ TAKE AT API LEVEL 5. THE CALLER MUST
/				/ PERFORM A DEBREAK PRIOR TO CALLING
/				/ THE EXECUTIVE.
/	...			/ ERROR RETURN, AC=RETURN CODE.
/
/ THE RETURN VALUES ARE:
/
/ NORMAL RETURN:
/
/ LINK = 0 IF THE TASK IS NORMAL MODE, 1 IF EXEC MODE.
/ STL NODE CONTAINS PBDL ADDRESS.
/ AC = 0.
/ API LEVEL = 5.
/
/ ERROR RETURN:
/
/ AC < 0 IF TERMINAL AC = 0 IF TRY LATER.
/
/
/ THERE WILL BE A LIMITATION ON THE MAXIMUM NUMBER OF PARTITIONS WHICH
/ CAN BELONG TO THE "TDV PARTITION POOL" OF 18. THIS NUMBER MAY BE
/ CHANGED BY ALTERING THE NUMBER OF ENTRIES IN THE TABLE "P.POOL"
 
P.FIT	XX		/ ROUTINE ENTRY POINT.
	LAC P.STL	/ FETCH STL ADDRESS.
	JMS SETXR	/ SET UP INDEXING.
	LAC S.EP,X	/ FETCH NORMAL/EXEC MODE INDICATOR.
	RTL		/ MOVE INDICATOR INTO SIGN BIT OF AC.
	SPA		/ EXEC MODE?
	JMP P.NORM	/ NO, NORMAL MODE.
	XX		/ THIS IS DEBUGGING CODE. THE SYSTEM	
			/ SHOULD NEVER GET HERE SINCE AN EXEC	
			/ MODE PARTITION WILL NEVER BE REQUESTED
			/ FROM JOB STATE 11.			
	CLA!CMA!STL	/ INDICATE ERROR.			
	ISZ P.FIT	/ MOVE TO ERROR RETURN.			
	JMP* P.FIT	/ BEWARE OF THIS RETURN.		
P.0015	JMS P.TERR	/ GENERATE ERROR MESSAGE.
	P.ER20		/ ERROR MESSAGE ADDRESS.
 
/ A NORMAL MODE TASK IS TO BE EXECUTED. THIS SECTION OF THE CODE WILL
/ BE RUN MOSTLY AT LEVEL 5 IN ORDER TO LOCK OUT SIGNIFICANT EVENT
/ RECOGNITION AND SWAPPING DURING THE FIT ALGORITHM.
 
P.NORM	LAC S.DP,X	/ FETCH FLAG WORDS.
	AND (S.ETDI)	/ CHECK FOR TASK DISABLED.
	SZA		/ AC = 0 MEANS NOT DISABLED.
	JMP P.0015	/ TASK DISABLED, DO NOT RUN.
	LAC S.TS,X	/ FETCH TASK SIZE.
	AND (S.ETS)	/ EXTRACT TASK SIZE.
	DAC P.TSKS	/ SAVE TASK SIZE FOR LATER.
	LAC UCAADR	/ FETCH UCA POINTER.
	JMS SETXR	/ SET UP FOR INDEXING.
	LAC U.PSC,X	/ FETCH PARTITION SELECTION CRITERIA.
	AND (377777)	/ REMOVE GLOBAL BIT.
	SAD (P.NAME)	/ THE PARTITION IS NAMED.
	SKP		/ YES.
	JMP P.0050	/ NO
	LAC (P.PBDL)	/ FETCH DEQ HEAD.
	DAC* (R1)	/ SET UP FOR SNAM.
	LAC UCAADR	/ FETCH ABSOLUTE ADDRESS OF UCA.
	AAC U.PSC+1	/ POINT TO ADDRESS OF NAME.
	DAC* (R2)	/ SNAM NOW COMPLETELY SET UP.
	JMS* (SNAM)	/ PARTITION HAD BETTER BE FOUND.
	JMP P.0049	/ ERROR, PARTITION HAS GONE AWAY.
	DAC P.TMP1	/ SAVE PBDL NODE ADDRESS.
	JMS SETXR	/ SET UP FOR INDEXING.
	LAC P.SZ,X	/ FETCH PARTITION SIZE.
	CMA!IAC		/ MAKE NEGATIVE.
	TAD P.TSKS	/ ADD IN TASK TO BE RUN SIZE.
	SMA!SZA		/ CHECK TASK SIZE. IS PARTITION BIG ENOUGH.
	JMP P.0048	/ PARTITION TOO SMALL.
	LAC (P.LVL5)	/ RAISE TO LEVEL 5.			
	ISA							
	LAC P.TC,X	/ FETCH TASK COUNT FROM PBDL.		
	SZA		/ IS THE PARTITION BUSY?		
	JMP P.0113	/ YES, STALL UNTIL NEXT TIME.		
P.0047	LAC P.STL	//FETCH STL NODE ADDRESS.
	JMS SETXR	//SET UP FOR INDEXING.
	LAC P.TMP1	//FETCH PBDL NODE ADDRESS.
	.INH							
	DAC S.PB,X	//ALL DONE, NODE SET UP.
	LAC S.DP,X	///FETCH FLAGS WORD.			
	AND (S.EDP)	///CLEAR ALL FLAGS.
	.ENB		///ENABLE
	DAC S.DP,X	///RESTORE FLAG WORDS.			
	LAC P.TSKS	//COUNT TASK SIZE.			
	CMA!IAC		//MAKE TASK SIZE POSITIVE.		
	JMS* TS.CTR	//IN TASK TABLE.			
	CLL!CLA		/ CLEAR THE LINK AND THE AC.
	JMP* P.FIT	/ RETURN TO THE CALLER, EVERYTHING IS OK.
P.0048	JMS P.TERR	/ PARTITION TOO SMALL, PRINT ERROR.
	P.ER50		/ ERROR MESSAGE ADDRESS.
P.0049	JMS P.TERR	/ PARTITION HAS GONE AWAY.
	P.ER60		/ ERROR MESSAGE ADDRESS.
 
/ THE PARTITION SELECTION CRITERIA WAS NOT A SPECIFIC PARTITION NAME.
/ FIGURE OUT WHETHER OR NOT IT IS A "MINIMUM SIZE" SELECTION.
 
P.0050	SAD (P.MINS)	/ IS THE SELECTION BASED ON A MINIMUM SIZE?
	SKP		/ YES.
	JMP P.0060	/ NO, MUST BE INCREMENT.
 
/ FIGURE OUT WHICH IS LARGER, TASK SIZE OR MINIMUM PARTITION SIZE.
 
	LAC U.PSC+1,X	/ FETCH PARTITION MINIMUM SIZE.
	CMA!IAC!CLL	/ MAKE IT NEGATIVE AND CLEAR THE LINK FOR LATER.
	TAD P.TSKS	/ ADD IN THE CURRENT SIZE.
	SPA		/ WHICH ONE GETS RETURNED?
	CLA		/ PARTITION SIZE.
	TAD U.PSC+1,X	/ TASK SIZE.
	JMP P.0070	/ GO JOIN COMMON CODE.
 
/ LAST OPTION IS TASK SIZE PLUS DELTA.
 
P.0060	LAC P.TSKS	/ FETCH TASK SIZE.
	TAD U.PSC+1,X	/ ADD IN DELTA.
P.0070	CMA!IAC		/ MAKE TASK SIZE NEGATIVE.
	DAC P.TSKS	/ STORE NEW TASK SIZE FOR FIT ALGORITHM.
 
/ PERFORM SET UP FOR PARTITION FITTING ALGORITHM.
 
	LAC (P.POOL-1)	/ SET UP X10 FOR FILLING POOL TABLE.
	DAC* (X10)
	LAC (P.PBDL)	/ FETCH LIST HEAD POINTER.
	DAC P.TMP1	/ START COUNTER.
	LAC (377777)	/ FETCH BEST DELTA PARTITION SIZE.
	DAC P.TMP3	/ INITIAL DELTA WILL ALWAYS KICK OUT.
	DAC P.TMP4	/ INITIAL TASK USE COUNT WILL ALSO KICK OUT.
	CLLR		/ CLEAR THE LIMIT REGISTER.
	LAC (P.LVL5)
	ISA		/ RAIS TO LEVEL 5 FOR SCAN.
 
/ PERFORM PARTITION FIT. UPON EXIT THE LR WILL CONTAIN 0 IF THERE
/ WAS NO PARTITION LARGE ENOUGH TO RUN THE TASK. OTHERWISE THE LR WILL
/ CONTAIN THE BEST FITTING PARTITION BLOCK ADDRESS. IN THE CASE OF
/ MORE THAN ONE PARTITION OF THE SAME SIZE THE LR WILL CONTAIN THE
/ PARTITION BLOCK WITH THE LOWEST USE COUNT. THIS IMPLIES THAT THE
/ LOAD WILL BE LEVELED ACROSS PARTITIONS IF THEY ARE ALL BUSY.
/
/ P.TMP4 WILL CONTAIN THE USE COUNT FOR THE BEST FITTING PARTITION.
/ X10 WILL POINT TO THE LAST USED WORD IN THE POOL TABLE.
 
P.0080	LAC* P.TMP1	//GET NEXT PDBL NODE TO PROCESS.
	SAD (P.PBDL)	//DONE WITH THE LIST?
	JMP P.0100	//YES, GO SET UP PARTITION.
	DAC P.TMP1	//SAVE FOR NEXT ITERATION OF LOOP.
	JMS SETXR	//SET UP FOR INDEXING.
	LAC P.N1,X	//FETCH PARTITION NAME (3CHAR)
	SAD (P.TDV)	//FIRST THREE CHARACTERS TDV?
	SKP		//YES.					
	JMP P.0080	//NO, DON'T LOOK AT THIS PARTITION.
 
/ A PARTITION OF THE FORM TDV??? HAS BEEN FOUND SINCE ALL PARTITIONS
/ OF THIS FORM ARE PART OF THE POOL CHECK FOR SIZE CONSTRAINTS.
 
	LAC P.SZ,X	//FETCH PARTITION SIZE.
	TAD P.TSKS	//CALCULATE PARTITION DELTA.
	SPA		//AC >= 0 IF TASK WILL FIT.
	JMP P.0080	//TASK WON'T FIT, RUN SOMEWHERE ELSE.
	DAC P.TMP2	//SAVE DELTA FOR DELTA COMPARISON LATER.
	LAC P.TC,X	//FETCH PARTITION USE COUNT.
	SZA		//IS IT IDLE?
	JMP P.0090	//NO, GO DO BEST FIT CHECK.
 
/ AN IDLE PARTITION WHICH WILL RUN THE TASK HAS BEEN LOCATED, MAKE
/ AND ENTRY IN THE POOL TABLE FOR THIS PARTITION.
 
	LAC P.TMP2	//FETCH DELTA.
	DAC* X10	//DELTA INTO POOL TABLE.
	LAC P.TMP1	//FETCH PBDL NODE ADDRESS.
	DAC* X10	//PBDL NODE ADDRESS INTO POOL TABLE.
 
/ CHECK THE PARTITION TO SEE IF IT FITS ANY BETTER THAN THE LAST
/ FITTING PARTITION.
 
P.0090	LAC P.TMP2	//FETCH CURRENT DELTA.
	CMA!IAC		//MAKE IT NEGATIVE.
	TAD P.TMP3	//ADD IN LAST BEST DELTA.
	SPA		//IS IT AT LEAST AS GOOD?
	JMP P.0080	//NO, GO TRY NEXT PARTITION.
 
/ THE CURRENT PARTITION IS AT LEAST THE SAME SIZE AS THE PREVIOUS
/ BEST FITTING PARTITION. CHECK TO SEE IF IT IS ANY BETTER.
 
	SZA		//IS IT ANY BETTER?
	JMP P.0095	//YES, GO UPDATE BEST FITTING CELLS.
 
/ THE PARTITION LOCATED IS THE SAME SIZE AS THE PREVIOUS PARTITION.
/ SELECT THE ONE WITH THE LOWEST USE COUNT. IF THEY HAVE THE SAME
/ USE COUNT, USE THE CURRENT PARTITION.
 
	LAC P.TC,X	//FETCH USE COUNT FOR THE PARTITION.
	CMA!IAC		//MAKE IT NEGATIVE.
	TAD P.TMP4	//ADD IN THE PREVIOUS PARTITIONS USE COUNT.
	SPA		//IS IT AT LEAST AS GOOD?
	JMP P.0080	//NO, KEEP THE CURRENT BEST FITTING PARTITION.
 
/ UPDATE ALL THE BEST FITTING CELLS TO INDICATE A NEW BEST FITTING
/ PARTITION.
 
P.0095	LAC P.TC,X	//FETCH TASK USE COUNT FROM PBDL.
	DAC P.TMP4	//UPDATE TASK COUNT.
	LAC P.TMP1	//FETCH PBDL NODE ADDRESS.
	PAL		//LR HAS NEW BEST FITTING NODE ADDRESS.
	LAC P.TMP2	//FETCH NEW PARTITIONS DELTA SIZE.
	DAC P.TMP3	//UPDATE OLD PARTITIONS DELTA SIZE.
	JMP P.0080	//GO CHECK THE NEXT PARTITIONS.
 
/ PARTITION FITTING IS OVER, SELECT A PARTITION TO USE.
 
P.0100	PLA		//FETCH PBDL NODE.
	SZA		//ANY PARTITIONS LARGE ENOUGH?
	JMP P.0110	//YES.
	JMS P.TERR	//NO, PRINT NO PARTITION LARGE ENOUGH.
	P.ER70		/ ERROR MESSAGE ADDRESS.
 
/ AT LEAST ONE PARTITION WILL RUN THE JOB. CHECK TO SEE IF THE BEST
/ FITTING ONE IS IDLE.
 
P.0110	DAC P.TMP1	//SAVE PBDL NODE ADDRESS FOR COMMON CODE.
	LAC P.TMP4	//FETCH USE COUNT FOR BEST FITTING PARTITION.
	SNA		//IS IT IDLE?
	JMP P.0047	//YES, GO SET UP STL.
 
/ THE BEST PARTITION IS BUSY. SEE IF ANY PARTITION IS FREE.
 
	LAC* (X10)	//FETCH UPDATED POOL TABLE POINTER.
	SAD (P.POOL-1)	//ARE THERE ENTRIES IN THE TABLE?
	SKP		//NO, TAKE ERROR RETURN WITH 0 AC.	
	JMP P.0115	//YES, TRY ONE OF THEM.			
P.0113	DBK		//RETURN TO LEVEL 7.			
	CLA!CLL		/ SET UP ERROR FLAG AND NORMAL MODE.	
	ISZ P.FIT	/ POINT TO ERROR RETURN.		
	JMP* P.FIT	/ TAKE ERROR RETURN.			
 
/ AT LEAST ONE OTHER PARTITION IS IDLE. SCAN THE IDLE LIST FOR THE
/ BEST AVAILABLE PARTITION AND SET UP A REQUEST FOR THAT ONE.
 
P.0115	LAC (P.POOL)	//FETCH POOL BEGINNING.			
	JMS SETXR	//ADJUST INDEX REGISTER.
	LAC* (X10)	//FETCH POINTER TO LAST USED WORD IN TABLE.
	TAD XRADJ	//SET UP LIMIT.
	PAL
	LAC (377777)	//FETCH INITIAL DELTA.
	DAC P.TMP1
P.0120	LAC 0,X		//FETCH DELTA FROM POOL TABLE.
	CMA!IAC		//MAKE IT NEGATIVE.
	TAD P.TMP1	//ADD IN CURRENT DELTA.
	SPA		//IS THE NEW DELTA SMALLER?
	JMP P.0130	//NO, ADVANCE TO NEXT TABLE ENTRY.
	LAC 0,X		//FETCH NEW DELTA.
	DAC P.TMP1	//UPDATE OLD DELTA.
	PXA		//FETCH INDEXING CONSTANT.
	DAC P.TMP2	//SAVE IT.
P.0130	AXS 2		//GO TO NEXT POOL TABLE ENTRY.
	JMP P.0120	//LOOP NOT OVER YET.
 
/ A NEW BEST FITTING ALTERNATIVE HAS NOW BEEN CHOSEN. FETCH THE
/ NODE ADDRESS FROM THE POOL TABLE AND GO JOIN COMMON CODE.
 
	LAC P.TMP2	//FETCH POINTER TO POOL TABLE ENTRY.
	PAX		//SET UP INDEXING FOR IT.
	LAC 1,X		//FETCH PBDL NODE ADDRESS.
	DAC P.TMP1	//SET UP COMMON CODE.
	JMP P.0047	//GO JOIN COMMON CODE.
	.TITLE *** SUBROUTINE FOR PARTITION FITTING ROUTINE ***
 
P.TERR	XX
	RPL		/ READ PRIORITY LEVELS.
	AND (P.LVL5\400000) / EXTRACT LEVEL 5 BIT.
	SZA		/ ENTERED AT LEVEL 5?
	DBK		/ YES.
	ISZ P.FIT	/ SET UP NORMAL ERROR RETURN.
	JMS* TDVTYP	/ PRINT ERROR MESSAGE.
	LAC TTYN	/ TERMINAL NUMBER.
	LAC* P.TERR	/ MESSAGE ADDRESS.
	LAC (2)		/ MODE.
	JMP* P.FIT	/ TAKE ERROR RETURN.
	.TITLE *** MISCELANEOUS SUBROUTINES ***
 
SETXR	XX
	TAD XRADJ
	PAX
	JMP* SETXR
	.END
