	.TITLE *** COPYRIGHT ***

/

/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 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 ***
 
/ 000	16-APR-76 (RCHM)	INITIAL IMPLEMENTATION COMPLETE	/(000)
/				RICHARD CLAGGET HLAVAC MUNROE	/(000)
/ 001	20-APR-76 (RCHM)	REMOVE TDV@@@ EXCLUSION.	/(001)
/ 002	25-APR-76 (RCHM)	IF A PARTITION FIT ERROR OCCURS	/(002)
/				RESET THE PARTITION SELECTION	/(002)
/				CRITERIA.			/(002)
/ 003	13-MAY-76 (RCHM)	FIX FOR THE NEW RANGE OF FININS	/(003)
/				EVENT VARIABLES.		/(003)
/ 004	15-JUL-76 (RCHM)	CHANGE THE DEFAULT STATE OF	/(004)
/				U.SSM TO -1 SINCE 0 IS A VALID	/(004)
/				TIME.				/(004)
/								/(005)
/ 005	30-JUL-76 (EAG)		INSERT FLAG BIT SO THAT BATCH	/(005)
/				WILL IGNORE PARTITION(S) BUSY	/(005)
/				MESSAGE.			/(005)
/								/(005)

	.TITLE *** MACROS FOR XQT PART 2 ***

 
	.GLOBL MA.NJB	/ COUNTER FOR TOTAL NUMBER OF JOBS.	
	.GLOBL TS.CTR	/ POINTER TO TASK COUNTING ROUTINE.
	.GLOBL TDVTYP	/ POINTER TO THE OVERLAY TERMINAL I/O	
			/ PROCESSOR.				

 

	.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

 

/ MACRO TO RETURN INCREMENTAL RETURN CODE. IF THE RETURN IS AN ERROR

/ THEN THE ARGUMENT TO THE MACRO MUST BE A "-" OTHERWISE IT MUST

/ BE A "+". THIS MACRO MUST BE READ AT BOTH PASS1 AND PASS2 TO WORK

/ PROPERLY.

 

	.DEFIN POSTEV,A

RT.CTR=0

	.DEFIN POSTEV,AA

RT.CTR=RT.CTR+1		/ INCREMENT RETURN COUNTER.

	LAC (AA@RT.CTR)	/ FETCH + OR - RETURN CODE.

	DAC U.OEV,X	/ POST OVERLAY EVENT VARIABLE.

	.ENDM

	POSTEV A

	.ENDM

/

/ 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 *** EQUATES FOR USER TASK DISPATCHER ***

 

P.TDV=240426

P.NAME=2

P.MINS=1

	STLOFF

	UCAOFF

P.N1=2

P.N2=3

P.SZ=5

P.FW=10

P.TC=47

X10=10

X11=11
SSM=160			/ OFFSET TO SECONDS SINCE MIDNIGHT.	

P.PBDL=250

RPL=705512

.INH=705522

.ENB=705521

ECLA=641000
CALX=010000		/ INDEXED CAL TO AVOID MACR15 PROBLEMS.	

P.ERIP=4

P.LVL5=400004

SNAM=123
R1=101

R2=102

OVID=302162

	.TITLE *** VARIABLES AND STORAGE FOR PARTITION FITTING ***

 

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		/ TASK SIZE (2'S COMPLEMENT)

P.ADJ	0

P.XUCA	0

P.AUCA	0

P.STL	0

SY.NSTL	0		/ POINTER TO NEW STL NODE.
SY.ERR	0		/ ERROR CODE FOR HANDLING EXEC LATER.
TTYN	0		/ TTY NUMBER IN CASE OF MESSAGE PRING.	
 
/ TABLE OF MESSAGE ADDRESSES.
 
TABLE	MSG1
	MSG2
	MSG3
	MSG4
	MSG5
	MSG6
	MSG7
	MSG10
	MSG11
	MSG12
	MSG13
 
DIS1	21		/ DISABLE ...REM

	0

	.SIXBT "...REM"

 

DIS2	21		/ DISABLE REM...

	0

	.SIXBT "REM..."

 

ENA1	22		/ ENABLE ...REM

	0

	.SIXBT "...REM"

 

ENA2	22		/ ENABLE REM...

	0

	.SIXBT "REM..."

RQAUTO	01		/ REQUEST CPB CODE.

	0		/ NO EVENT VARIABLE.

	.SIXBT "AUTORM"	/ TASK NAME.

	0		/ USE DEFAULT PRIORITY.

 

P.ER10	TEXT <XQT -- CAN'T RUN EXEC MODE TASK>
P.ER20	TEXT <XQT -- CAN'T RUN TASK DISABLED>
P.ER50	TEXT <XQT -- CAN'T RUN PARTITION IS TOO SMALL>
P.ER60	TEXT <XQT -- CAN'T RUN PARTITION IS NO LONGER IN SYSTEM>	
P.ER70	TEXT <XQT -- CAN'T RUN NO PARTITION IS BIG ENOUGH FOR TASK>
MESS2	MS2END-.*400&377000+400002	/ THIS MESSAGE IGNORED	/(005)
	0				/ BY BATCH.
	.ASCII :PARTITION(S) BUSY:<15>
MS2END=.
	.GLOBL XQT2	/ ENTRY POINT TO USER TASK DISPATCHER.
 
/ MESSAGES TO GO ALONG WITH TABLE.
 
MSG1	TEXT <XQT -- ILLEGAL LUN>
MSG2	TEXT <XQT -- HINF ERROR>
MSG3	TEXT <XQT -- ILLEGAL DEVICE>
MSG4	TEXT <XQT -- DISK DISMOUNTED>
MSG5	TEXT <XQT -- GET ERROR>
MSG6	TEXT <XQT -- FILE NOT 'CREATED'>
MSG7	TEXT <XQT -- FILE NOT FOUND>
MSG10	TEXT <XQT -- ALLOCATE ERROR>
MSG11	TEXT <XQT -- PUT ERROR>
MSG12	TEXT <XQT -- TASK ALREADY ACTIVE>
MSG13	TEXT <XQT -- SYST. ERR. NON-UNIQUE ALIAS NAME>
	.TITLE *** CODE OF USER TASK DISPATCHER ***

 

XQT2	XX		/ ENTRY POINT.

	DAC P.AUCA	/ SAVE THE ABSOLUTE ADDRESS OF THE UCA.

	CAL DIS1	/ DISABLE ...REM

	CAL DIS2	/ DISABLE REM...

	LAC (.)		/ CALCULATE THE

	AND (70000)	/ INDEX MODE

	CMA!IAC		/ FUDGE FACTOR

	DAC P.ADJ	/ AND SAVE IT.

	TAD P.AUCA	/ CALCULATE THE INDEXING FACTOR TO THE UCA.

	DAC P.XUCA	/ SAVE THE UCA INDEXING VALUE.

	PAX		/ SET UP TO INDEX INTO THE UCA.

	LAC (OVID)	/ FETCH OVERLAY ID.

	DAC U.OVID,X	/ IDENTIFY THE OVERLAY IN THE UCA.
	LAC U.TTYN,X	/ FETCH TERMINAL NUMBER FOR CALL TO 	
	DAC TTYN	/ TDVTYP.				

 

/ FETCH THE NODE ADDRESS FROM THE EVENT VARIABLE. IF THE VALUE IS
/ NEGATIVE USE IT AS AN INDEX TO A MESSAGE ADDRESS.

 

	LAC U.MAEV,X	/ FETCH STL NODE ADDRESS.
	SMA		/ DID AN ERROR OCCUR?
	JMP SY.000	/ NO, CONTINUE.
	LAC (6)		/ SET UP EXIT.
	DAC U.JSW,X	/ NEW READ SET UP.
	POSTEV -	/ FLAG ERROR.
	LAC U.MAEV,X	/ FETCH ERROR CODE.
	CMA		/ MAKE IT POSITIVE.			/(003)
	PAX		/ SET UP TO ACCESS MESSAGE TABLE.
	AXR -377	/ DECREMENT THE INDEX REGISTER TO AVOID	/(003)
			/ BANK ERROR.				/(003)
	LAC TABLE-1,X	/ FETCH MESSAGE ADDRESS.
	DAC P.TMP1	/ SAVE MESSAGE ADDRESS.
	JMS* TDVTYP	/ PRINT ERROR MESSAGE.
	LAC TTYN
	LAC P.TMP1
	LAC (2)
	JMP* XQT2
 
/ STL NODE ADDRESS IS IN THE AC.
 
SY.000	DAC SY.NSTL	/ SAVE NEW NODE ADDRESS FOR LOTS OF PEOPLE.
	ISZ SY.ERR	/ SET ERROR CODE NON ZERO (NO ERROR)
	JMS P.FIT	/ CALL PARTITION FITTING ROUTINE.
	LAC SY.NSTL	/ PASS P.FIT THE STL ADDRESS.
	JMP SY.003	//NORMAL EXIT AT API LEVEL 5.
	DAC SY.ERR	/ SAVE ERROR CODE IN CASE IT'S 0.
	SMA!CLL		/ TERMINAL ERROR? SET UP NORMAL MODE TASK INDICATOR IN LINK
	JMP SY.003	/ NO.
	LAC SY.NSTL	/ FETCH STL NODE ADDRESS.
	JMS SETXR
	DZM S.N1,X	/ CLEAR NAME FIELD.
	DZM S.N2,X
	LAC (S.EROX!S.ETEX) / SET REMOVE ON EXIT AND TASK EXITTED.
	DAC S.DP,X
	CAL ENA1	/ ENABLE ...REM
	CAL ENA2	/ ENABLE REM...
	CAL RQAUTO	/ REQUEST AUTO REM.
	LAC P.XUCA	/ FETCH INDEXING TO UCA.
	PAX		/ SET UP TO ACCESS UCA.
	LAC (6)		/ SET UP A NEW READ ON RETURN TO POLLER.
	DAC U.JSW,X	/ UCA HAS NEW STATUS CODE.
	POSTEV -	/ RETURN NEGATIVE OVERLAY EVENT VARIABLE.
	LAC U.PSC,X	/ FETCH PSC.				/(002)
	SPA		/ RESET IF KEEP NOT ON.			/(002)
	JMP* XQT2	/ KEEP ON, RETURN TO POLLR.		/(002)
	DZM U.PSC,X	/ SET PSC TO SYSTEM DEFAULTS.		/(002)
	LAC (1400)	/					/(002)
	DAC U.PSC+1,X						/(002)
	JMP* XQT2	/ RETURN TO POLLER.
 
/ EITHER A PARTITION WAS FOUND WHICH IS IDLE AND CAN RUN THE TASK
/ OR NO IDLE PARTITION WAS AVAILABLE. SY.ERR DEFINES THE CASE. BUILD
/ A MAPPED REQUEST FOR THE TASK AND EXECUTE IT IF POSSIBLE.
 
SY.003	LAC P.XUCA	//SET UP TO ACCESS THE UCA.
	PAX		//
	LAC (4)		//SIGNAL USER TASK EXECUTION.
	DAC U.JSW,X	//

 

/ BUILD THE REST OF THE MAPPED REQUEST CAL AND ISSUE IT IF POSSIBLE.

 

	LAC SY.NSTL	//FETCH STL NODE ADDRESS.

	DAC U.CPB,X	//STORE IN CPB AREA.

	LAC U.CPB+10,X	//FETCH TASK NAME.

	DAC U.CPB+3,X	//AND STORE IT INTO REQUEST CPB.

	LAC U.CPB+11,X	//

	DAC U.CPB+4,X	//

	LAC (36)	//FETCH MAPPED REQUEST CAL CODE.

	DAC U.CPB+1,X	//STORE IT IN THE UCA.

	LAC P.AUCA	//CALCULATE AN EVENT VARIABLE ADDRESS.

	AAC U.MAEV	//USE THE UCA USER'S EVENT VARIABLE.

	DAC U.CPB+2,X	//STORE EV ADDRESS IN CPB.
	.DEC							/(002)
	LAC (280)	//ALL MULTIACCESS JOBS RUN AT 280.	/(002)
	.OCT							/(002)
	DAC U.CPB+5,X	//STORE PRIORITY IN CPB.		/(002)
	LAC U.ULOF,X	//FETCH LUN OFFSET AND USER NUMBER.

	DAC U.CPB+6,X	//LAST WORD IN CPB NOW SET UP.

 

/ THE MAPPED REQUEST CAL PARAMETER BLOCK IS SET UP, THE NEW STL

/ NODE IS ON THE STL. THE ONLY THING PREVENTING US FROM DOING ANYTHING

/ IS THE POSSIBILITY OF NO FREE PARTITIONS.

 

	LAC SY.ERR	//ARE THERE ANY FREE PARTITIONS?
	SNA!CLA!CMA	//YES, GO ISSUE REQUEST.		/(004)
	JMP SY.004	//NO, RESET JOB STATUS AND CONTINUE.
	DAC U.SSM,X	//CLEAR SECONDS SINCE MIDNIGHT CTR	/(004)

	DBK		//LOWER TO TASK LEVEL.
	CALX U.CPB+1	///EXECUTE CONSTRUCTED CAL.		
	ISZ* MA.NJB	/ COUNT JOB JUST REQUESTED.		

	CAL ENA1	/ ENABLE REM...

	CAL ENA2	/ ENABLE ...REM

	LAC P.XUCA	/ NOW WE CHECK THAT THE CAL GOT ISSUED PROPERLY.

	PAX		/ SET UP FOR UCA ACCESS.

	LAC U.MAEV,X	/ IS EVERYTHING OK?

	SMA		/ AC < 0 IF NOT.

	JMP SY.005	/ TAKE NORMAL RETURN.

	JMS T.TERR	/ PRINT ERROR MESSAGE.

	LAC P.XUCA

	PAX

	LAC (6)		/ SET UP A READ FOR THIS UCA.

	DAC U.JSW,X	/ SET JOB STATUS.

	POSTEV -

	JMP* XQT2	/ RETURN TO POLLER.

SY.005	POSTEV +	/ NORMAL RETURN.

	JMP* XQT2	/ RETURN TO POLLER.
SY.004	LAC* (SSM)	//FETCH SECONDS SINCE MIDNIGHT CTR.	
	DAC U.SSM,X	//STORE THE START OF WAITING IN UCA.	
	DBK		//					

	LAC (12)	/ WAIT FOR PARTITION TO FREE UP.

	DAC U.JSW,X	/ SET JOB STATE IN JSW.

	POSTEV +	/ NORMAL COMPLETEION.
	JMS* TDVTYP	/ PTINT THE MESSAGE.			
	LAC TTYN	/ FETCH TERMINAL NUMBER.		
	LAC (MESS2)	/ FETCH MESSAGE ADDRESS.		
	LAC (2)		/ FETCH THE MODE.			

	JMP* XQT2	/ RETURN TO POLLER.

	.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 UCAADR

/	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:

/

/ 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 A TERMINAL ERROR WAS DETECTED. AC = 0 IF THE CALLER SHOULD

/ SET UP JOB STATE 11.

/

/

/

/

/ 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.

 

/ COPY THE INPUT PARAMETERS FROM THE CALLER.

 

	XCT* P.FIT	/ FETCH THE STL NODE ADDRESS.

	TAD P.ADJ	/ FUDGE THE STL NODE ADDRESS FOR INDEXING.

	DAC P.STL

	PAX

	ISZ P.FIT	/ POINT TO THE RETURN ADDRESS.

 

/ FIRST CHECK TO SEE IF THE TASK TO BE EXECUTED IS AN EXEC MODE

/ TASK.

 

	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.

	JMS P.TERR	/ USER CANNOT XQT AN EXEC MODE TASK.
	P.ER10
 
P.0015	JMS P.TERR	/ TASK IS DISABLED.
	P.ER20

 

/ 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 P.XUCA	/ FETCH UCA POINTER.

	PAX		/ SET UP 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 P.AUCA	/ 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.

	TAD P.ADJ	/ SET UP ADJUST FOR INDEXING.

	PAX		/ XR NOW POINTS TO PBDL.

	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 CCOUNT FROM PBDL.		
	SZA		//IST THE PARTITION BUSY?>		
	JMP P.0113	//YES, RETURN.				

P.0047	LAC P.STL	//FETCH STL NODE ADDRESS.

	PAX		//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 THE TASK ABOUT TO BE REQUESTED.
	CMA!IAC		//MAKE THE TASK SIZE POSITIVE.		

	JMS* TS.CTR	//CALL RESIDENT ROUTINE.

	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.

	LAC P.TSKS	/ WHICH ONE SHOULD I USE?

	SNL		/ LINK = 1 => OVERFLOW TASK SIZE IS LARGER.

	LAC U.PSC+1,X	/ FETCH CURRENT 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.

	TAD P.ADJ	//SET UP FOR INDEXING.

	PAX		//SET UP XR.

	LAC P.N1,X	//FETCH PARTITION NAME (3CHAR)

	SAD (P.TDV)	//FIRST THREE CHARACTERS TDV?
	SKP		//YES.					/(001)

	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 THE IDLE ONES.
P.0113	DBK		//RETURN TO API LEVEL 7.		

	CLA!CLL		//INDICATE NON TERMINAL ERROR AND NORMAL MODE.

	ISZ P.FIT	/ POINT TO ERROR RETURN
	JMP* P.FIT	/ RETURN TO CALLER.			

 

/ 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.

	TAD P.ADJ	//SET UP INDEXING.

	PAX

	LAC* (X10)	//FETCH POINTER TO LAST USED WORD IN TABLE.

	TAD P.ADJ	//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 ADDRESS.	
	JMS* TDVTYP	/ CALL TYPE ROUTINE TO PRINT THE MESSAGE
	LAC TTYN	/ FETCH THE TERMINAL NUMBER.		
	LAC* P.TERR	/ FETCH THE MESSAGE ADDRESS.		
	LAC (2)		/ SET UP IOPS ASCII MODE.		
	LAC* P.TERR	/ FETCH MESSAGE ADDRESS.		
	DAC* (X10)	/ SET UP TO FETCH ERROR RETURN CODE.	
	LAC* X10	/ FETCH ERROR RETURN CODE.		

	JMP* P.FIT	/ RETURN WITH ERROR CODE IN AC.

	.TITLE *** ERROR PRINTING ROUTINE FOR FAILED REQUEST ***

 

/ ERROR CODE IN AC. ASSUMES THAT SAV.XL HAS BEEN CALLED.	

 

T.TERR	XX							
	CMA!IAC		/ CONVERT EV TO POSITIVE NUMBER.	
	LRSS!CLQ 6						

	ALS 4							
	LLS 3							

	ALS 4							
	XOR (301406)	/ MAGIC NUMBER TO CONVERT TO 5/7.	

	DAC EBUF	/ SAVE FIRST 2 4/7 CHARACCTERS.		

	LACQ		/ FETCH 3/7 CHARACTER.			

	XOR (6400)	/ SET UP CR.				

	DAC EBUF+1	/ COMPLETE MESSAGE. NOW SEND IT.	
	JMS* TDVTYP	/ PINT ERROR MESSAGE.			
	LAC TTYN	/ FETCH TERMINAL NUMBER.		
	LAC (TWRIT)	/ FETCH MESSAGE ADDRESS.		
	LAC (2)		/ FETCH MODE.				

	JMP* T.TERR	/ RETURN TO CALLER.			

 
TWRIT	EBUF+2-.*400&777000+2					

	0
	.ASCII "REQUEST ERROR -- EV = -"			

EBUF	0							

	0							

	.EJECT

 

SETXR	XX

	TAD P.ADJ

	PAX

	JMP* SETXR

	.END
