*DECK EXSQUEZ
PROC SQUEEZE ( (REQSIZE), RETFWA );
BEGIN # SQUEEZE #
*IF DEF,IMS
#
**
*
* 1. PROC NAME AUTHOR DATE
* SQUEEZE M. D. PICKARD 76/11/17
*
* 2. FUNCTIONAL DESCRIPTION
* SQUEEZE WILL MOVE ASSIGNED BLOCKS THAT ARE NOT FIXED POSITION
* UNTIL A FREE BLOCK LARGE ENOUGH TO SATISFY THE REQUEST EXISTS.
* MORE FIELD LENGTH WILL BE REQUESTED IF THIS CANT BE DONE.
* ALSO, IF THE REQUEST SIZE IS ZERO, SQUEEZE WILL MOVE AS
* MUCH AS POSSIBLE AND RETURN THE ADDRESS OF THE LAST FREE
* BLOCK.
*
* 3. METHOD USED
* STARTING AT TSBFWA, ALL ASSIGNED BLOCKS THAT ARE NOT FIXED
* POSITION ARE MOVED TO LOWER CORE ADDRESSES AND FREE BLOCKS
* ARE ACCUMULATED TO MAKE LARGER FREE BLOCK. WHEN A FREE
* BLOCK EXISTS THAT SATISFIES THE REQUEST SIZE, THE FUNCTION
* IS COMPLETE. IF WHEN CTSBLWA IS REACHED AND THE REQUEST
* IS NOT SATISFIED, MORE FIELD LENGTH IS REQUESTED TO SATISFY
* THE REQUEST. (IF THE REQUEST SIZE WAS ZERO, WHEN CTSBLWA
* IS REACHED, THE ADDRESS OF THE LAST FREE BLOCK IS RETURNED
* AND NO FIELD LENGTH REQUEST TAKES PLACE.) THE ADDRESS OF
* THE BLOCK SATISFYING THE REQUEST IS RETURNED.
*
* 4. ENTRY PARAMETERS
* A. FORMAL PARAMETERS
* REQSIZE SIZE OF FREE BLOCK NEEDED, REQSIZE
* MUST BE GQ ZERO, AND LQ MAXTSBL
*
* B. TSB MANAGER GLOBAL PARAMETERS
* TSBFWA FIRST WORD ADDRESS OF TSB"S
* CTSBLWA CURRENT LAST WORD ADDRESS OF TSB"S
* TSBAREA ARRAY THAT DEFINES DYNAMIC MEMORY
* TSBIT TASK SEQUENCE BLOCK IDENT TABLE
* THIS BASED ARRAY IS SET ON ENTRY
*
* 5. EXIT PARAMETERS
* A. FORMAL PARAMETERS
* RETFWA ADDRESS OF TSB THAT SATISFIES REQUEST
* LAST FREE TSB ADDRESS IF REQUEST SIZE
* WAS ZERO
* B. TSBMGR GLOBAL PARAMETERS
* TTSBFWA FIELD IN TSBIT THAT IS MODIFIED EACH TIME
* TSBIT THIS BASED ARRAY GETS RESET IF TSB
* CONTAINING TSBIT IS MOVED
*
* 6. COMDECKS CALLED
* TSBBASE TSB MANAGER BASED ARRAY DEFINITIONS
* TSBDATA TSB MANAGER DATA AREA DEFINITIONS
* TSBDEFS TSB MANAGER SYMPL DEFS
*
* 7. ROUTINES CALLED
* MEMREQ REQUESTS MEMORY
* MOVEI MOVES BLOCK OF CENTRAL MEMORY WORDS
*
* 8. DAYFILE MESSAGE
* NONE.
*
#
*ENDIF
CONTROL NOLIST; # STOPS LIST TSBDEFS,TSBDATA,TSBBASE #
*CALL CYBERDEFS
*CALL TSBDEFS
*CALL TSBBASE
*CALL TSBDATA
CONTROL LIST;
ITEM
REQSIZE U, # SIZE OF TSB WANTED #
RETFWA U; # ADDRESS OF TSB LARGE ENOUGH FOR REQUEST #
# OR LAST FREE TSB ADDRESS #
XREF
BEGIN
PROC FIRSTF;
PROC GETBIG;
PROC MOVEI;
PROC MEMREQ;
END
ITEM
CFREE U, # CURRENT ACCUMULATED FREE SPACE #
CSPOT U, # CURRENT SPOT IN SEARCH #
FSPOT U, # FREE SPACE STARTING SPOT #
LPTSBL U, # LAST PREVIOUS TSB LENGTH #
MRSIZE U, # USED TO HOLD MEMORY REQUEST VALUE #
NMEMREQ B, # NO MEMORY REQUEST INDICATOR #
SQSIZE U; # TEMPORY HOLDER FOR REQUEST SIZE #
CSPOT = 0;
FSPOT = 0;
LPTSBL = 0;
IF REQSIZE EQ 0
THEN # NO FIELD LENGTH IS REQUESTED #
BEGIN
NMEMREQ = TRUE; # SET NO MEMORY REQUEST #
SQSIZE = MAXTSBA + 1; # FORCE NO MATCH ON REQUEST SIZE #
END
ELSE # FIELD LENGTH WILL BE REQUESTED IF #
BEGIN # NEEDED #
SQSIZE = REQSIZE; # SET SEARCH SIZE TO REQUEST SIZE #
NMEMREQ = FALSE; # SET TO ALLOW MEMORY REQUEST #
END
FOR CFREE = 0 WHILE CFREE LS SQSIZE DO
BEGIN # CONSOLIDATE TSB AREA WHERE POSSIBLE #
# UNTIL REQUEST IS SATISFIED #
IF LOC(TSBAREA[CSPOT]) GQ CTSBLWA
THEN # AT THE END OF THE TSB AREA #
BEGIN
IF NOT NMEMREQ
THEN # MORE FIELD LENGTH IS WANTED #
BEGIN
MRSIZE = ( SQSIZE - CFREE + ( MRU - 1 )) / MRU; # AMOUNT #
MEMREQ(MRSIZE); # REQUEST MRSIZE MEMORY REQUEST UNITS #
CFREE = CTSBLWA - LOC(TSBAREA[FSPOT]); # AMOUNT OF FREE NOW#
P<FTSBHDR> = LOC(TSBAREA[FSPOT]); # SET HDR. AT LAST FREE #
FTSBL[0] = CFREE; # SET THIS BLOCKS NEW LENGTH #
P<FTSBHDR> = CTSBLWA; # BUILD ZERO LENGTH TSB AT CTSBLWA #
FBUSY[0] = FALSE; # SET NOT BUSY #
FNOTMOV[0] = FALSE; # SET OK TO MOVE #
FHDRRSV[0] = 0; # CLEAR RESERVED AREA #
FIDENT[0] = 0; # CLEAR IDENT FIELD #
FPTSBL[0] = CFREE; # SET PREVIOUS TSB LENGTH #
FTSBL[0] = 0; # SET TSB LENGTH TO ZERO #
END
ELSE # NO MORE FIELD LENGTH #
BEGIN
SQSIZE = 0; # SET TO INSURE END OF FOR LOOP #
IF CFREE NQ 0
THEN # LAST TSB IS A FREE ONE #
BEGIN
P<FTSBHDR> = CTSBLWA; # SET FREE FORMAT ON ZERO LEN. TSB #
FPTSBL[0] = CFREE; # PREVIOUS LEN. IS CFREE #
END
END
END
ELSE # CONTINUE CONSOLIDATION #
BEGIN
P<BTSBHDR> = LOC(TSBAREA[CSPOT]); # SET HEADER AT CURR. SPOT #
IF BBUSY[0]
THEN # THIS TSB IS ASSIGNED #
BEGIN # SEE IF THERE IS ANYWHERE TO MOVE IT #
IF CSPOT NQ FSPOT
THEN # WE CAN MOVE IT IF IT IS NOT FIXED #
IF NOT BNOTMOV[0]
THEN # IT CAN BE MOVED, SO MOVE IT #
BEGIN
BPTSBL[0] = LPTSBL; # NEW PREVIOUS TSB LENGTH #
LPTSBL = BTSBL[0]; # NEW LAST PREVIOUS TSB LENGTH #
TTSBFWA[BIDENT[0]] = LOC(TSBAREA[FSPOT]); # NEW FWA TO #
# TSBIT #
IF BIDENT[0] EQ 1
THEN # THIS IS THE TSBIT, RESET BASED ARRAY #
P<TSBIT> = LOC(TSBAREA[FSPOT]) + TSBHDRL; # SET ARRAY#
MOVEI(LPTSBL,LOC(TSBAREA[CSPOT]),LOC(TSBAREA[FSPOT]));
# MOVE TSB TO NEW LOCATION #
CSPOT = CSPOT + LPTSBL;
P<FTSBHDR> = LOC(TSBAREA[FSPOT]) + LPTSBL;
FBUSY[0] = FALSE; # BUILD FREE HEADER AT END OF MOVED #
FNOTMOV[0] = FALSE; # ITS MOVEABLE TSB #
FHDRRSV[0] = 0; # CLEAR RESERVED AREA #
FIDENT[0] = 0; # CLEAR IDENT FIELD #
FPTSBL[0] = LPTSBL; # SET PREVIOUS LENGTH TO MOVED TSB #
FTSBL[0] = CFREE; # SET LENGTH TO CURRENT FREE SPACE #
FSPOT = FSPOT + LPTSBL; # RESET FREE SPOT #
P<BTSBHDR> = LOC(TSBAREA[CSPOT]); #POINT AT NEXTTSB#
BPTSBL[0] = CFREE ; # SET NEW PREV TSB LENGTH#
END
ELSE # CANT MOVE IT #
BEGIN
LPTSBL = BTSBL[0]; # NEW LAST PREVIOUS LENGTH #
BPTSBL[0] = CFREE; # NEW PREVIOUS TSB LENGTH FOR BLOCK #
CFREE = 0;
CSPOT = CSPOT + BTSBL[0]; # NEW CURRENT SPOT #
FSPOT = CSPOT; # NEW FREE SPOT, SAME A CURRENT SPOT #
END
ELSE # NOWHERE TO MOVE IT, RESET POINTERS #
BEGIN
CSPOT = CSPOT + BTSBL[0]; # NEW CURRENT SPOT #
FSPOT = CSPOT; # NEW FREE SPOT #
LPTSBL = BTSBL[0]; # NEW LAST PREVIOUS TSB LENGTH #
END
END
ELSE # THIS IS A FREE TSB, ADD IT TO CFREE #
BEGIN
CFREE = CFREE + BTSBL[0]; # ADD TO ACCUMULATED FREE SPACE #
P<FTSBHDR> = LOC(TSBAREA[FSPOT]); # SET ON LAST FREE #
FTSBL[0] = CFREE; # UPDATE LENGTH OF FREE TSB #
CSPOT = CSPOT + BTSBL[0]; # NEW CURRENT SPOT #
P<BTSBHDR>= LOC(TSBAREA[CSPOT]); #POINT TO NEXT TSB#
BPTSBL[0] = CFREE ; #SET NEW PREV. TSB LENGTH #
IF LOC(TSBAREA[CSPOT]) EQ CTSBLWA
THEN # RESET PREV. TSB LEN. ON LAST TSB #
BEGIN
P<BTSBHDR> = LOC(TSBAREA[CSPOT]); # FORMAT LAST TSB #
BPTSBL[0] = CFREE; # PREVIOUS TSB LENGTH #
END
END
END
END
FIRSTF; # RESET FFFWA #
GETBIG; # RE-ESTABLISH BIGGEST FREE TSB SIZE #
RETFWA = LOC(TSBAREA[FSPOT]); # SET RETURN FWA FOR TSB #
RETURN;
END TERM # SQUEEZE #