*DECK MRELS
IDENT MRELS
ENTRY MRELS
EXT ABORT
EXT BFSCAN
EXT XTRACE
EXT OMSG
EXT RDUMP
EXT XDROP
LIST F
*IF DEF,IMS
*#
*1DC MRELS 000100
* 1. PROC NAME AUTHOR DATE 000110
* MRELS P. C. TAM 77/09/27
* 000130
* 2. FUNCTIONAL DESCRIPTION. 000140
* THIS ROUTINE IS RESPONSIBLE FOR RELEASING ONE BUFFER 000150
* OF THE SPECIFIED FWA TO THE FREE CHAIN. 000160
* 000170
* 3. METHOD USED. 000180
* CALLING ROUTINES PASS THE FWA OF BUFFER TO BE RELEASED. 000190
* INCREMENT TOTAL NUMBER OF WORDS OF FREE CHAIN. 000200
* SCAN THROUGH FREE CHAIN FOR PROPER POSITION TO CHAIN THE 000210
* BUFFER BEING RELEASED. 000220
* WHEN PROPER POSITION FOUND. CHECK WHETHER FORM CONTIGUOUS 000230
* BUFFER WITH PRECEEDING OR FOLLOWING FREE BUFFERS OR NOT. 000240
* DO THE LINKING. 000250
* 000260
* 4. ENTRY PARAMETERS. 000270
* BUFWA FWA OF BUFFER TO RELEASE 000280
* 000290
* 5. EXIT PARAMETERS. NONE 000300
* 000310
* 6. COMDECKS CALLED. 000320
* CYBERDEFS FREETAB INPARU MACDEF
* STATTAB2
* 000360
* 7. ROUTINES CALLED. 000370
* OMSG DAYFILE MESSAGE
* RDUMP DUMP NIP ADDRESS SPACE
* XDROP SET PIP DROP FLAG
* XTRACE RECORD CALL 000390
* 000400
* 8. DAYFILE MESSAGES.
* *MRELS BUFFER MANAGEMENT ERROR*
* 000420
*#
*ENDIF
*CALL MACDEF
*CALL CYBERDEFS
*CALL INPARU
*CALL FREETAB
*CALL STATTAB2
MRELS SUBR = ENTRY/EXIT
IFEQ DEBUG,1,6
SX6 A1
SA6 TEMP
SX1 XMRELS
RJ XTRACE
SA1 TEMP
SA1 X1
SA2 X1 (X2)=(BUFWA)
MX0 -FRBBS$ (X1)=FRBBS[BUFWA] RIGHT JUSTIFIED
LOAD A5,X2,FRBBS# (X5)=FRBBS[BUFWA] WORD
LX0 FRBBS?-FRBBS$+1
BX1 -X0*X5
LX1 -FRBBS?+FRBBS$-1
D2 IFEQ DEBUG,1
NZ X1,MRLD1
SA1 MSGDR
RJ ABORT *---ABORT---*
MRLD1 BSS 0
D2 ENDIF
IFEQ STAT,1,4
MX0 -1 INCREMENT ST$REL
SA5 ST$REL
IX6 X5-X0
SA6 ST$REL
* INCREASE FREE CHAIN SIZE
SA5 FRETAB+FRESFB#
IX6 X5+X1
SA6 A5
***
*
* STEP 2 SCAN THRU FREE CHAIN FOR PROPER POSITION TO LINK RELEASED
* BUFFER
* WHEN EXIT FROM THIS STEP:
* (B4) = PREBUF VALUE (PRECEDING BUFFER BASE ADDRESS)
* (B5) = FOBUF VALUE (NEXT BUFFER BASE ADDRESS)
* (B2) = BUFWA VALUE (BUFFER BEING RELEASED BASE ADDRESS)
* (B3) = FRENOFB VALUE(NO. OF FREE BUFFER)
SA5 FRETAB+FREFBFP# READ FREFBFP WORD FROM CM
SB5 X5 (B5)=FREFBFB VALUE (FOBUF)
SB4 FRETAB (B4)=LOC(FRETAB) (PREBUF)
SA5 FRETAB+FRENOFB# READ FRENOFB WORD FROM CM
SB3 X5 (B3)=FRENOFB VALUE
SB2 X2 (B2)=BUFWA (BUFWA)
SB1 1 INITIALIZE LOOP COUNTER
MRLS1 GT B5,B2,FOUND IF FOBUF GR BUFWA, GO TO FOUND
SB4 B5 PREBUF SET TO FOBUF
LOAD A5,B5,FRBFBFP# (X5)=FRBFBFP[FOBUF] WORD
SB5 X5 GET ONLY FRBFBFP FIELD
SB1 B1+1 INCR. LOOP COUNTER
LE B1,B3,MRLS1
***
*
* STEP 3 FOUND PROPER POSITION FOR RELEASE BUFFER
* CHECK WHETHER FORM CONTIGUOUS BLOCK WITH PRECEEDING OR
* FOLLOWING BUFFERS
* WHEN EXIT FROM THIS STEP:
* (B7) = PREBUF+FRBBS[PREBUF] (LWA+1 OF PRECEDING BUFFER) TEMP1
* (B6) = BUFWA+FRBBS[BUFWA] (LWA+1 OF RELEASE BUFFER ) TEMP2
* B4, B5, B2, B3 ARE PERSERVED FROM PREVIOUS STEP
FOUND BSS 0
DZ IFEQ STAT,1
SX6 B1 (X6)=NO OF BUFFERS EXAMINED
SA5 ST$RNB UPDATE NO OF FREE BUFFERS TRANSVERSES
IX6 X6+X5
SA6 A5
DZ ENDIF
LOAD A5,B4,FRBBS# (X5)=FRBBS[PREBUF] WORD
MX0 -FRBBS$ MASK FOR FRBBS$ FIELD
LX0 FRBBS?-FRBBS$+1 SHIFT TO APPR POS. IN WORD
BX6 -X0*X5 GET FRBBS FIELD ONLY
LX6 -FRBBS?+FRBBS$-1 FRBBS FD RIGHT JUSTIFY
SB7 B4+X6 (B7)=PREBUF+FRBBS[PREBUF] LWA+1 OF PRE BLK
SB6 B2+X1 (B6)=BUFWA+FRBBS[BUFWA] LWA+1 OF RELEASE BF
D1 IFEQ DEBUG,1
LT B2,B4,MRLS5 BUFWA GQ PREBUF AND
LT B2,B7,MRLS15 BUFWA LS TEMP1, BRANCH TO MRLS15
MRLS5 LE B6,B5,MRLS10 TEMP2 GR FOBUF AND
SB1 FRETAB+FRE1# FOBUF NQ LOC(FRE1)
NE B5,B1,MRLS15 BRANCH TO MRLS15
MRLS10 SA5 CTLSFWA BUFWA LS CTLSFWA,
SB1 X5 BRANCH TO MRLS15
GE B2,B1,MRLS20
MRLS15 BSS 0
SA1 MSGDR READ MSG CM ADDRESS
RJ ABORT *---ABORT---*
D1 ENDIF
***
*
* LINK BUFFER TO THE FREE CHAIN
MRLS20 LX1 FRBBS?-FRBBS$+1 SHIFT TO APP POS IN WORD
NE B2,B7,MRLSY BRANCH IF BUFWA NE TEMP1
NE B5,B6,MRLSZ BRANCH IF FOBUF NE TEMP2
**
*
* CASE 1 RELEASE BUF FORM CONTIGUOUS BLK WITH BOTH PRE AND FO BLKS
*
* FOLLOWING INSTRUCTIONS PRESERVES:
* (X7) = FRBBS[PREBIF]+FRBBS[BUFWA]+FRBBS[FOBUF]
* (X3) = FRBWD[FOBUF]
MX0 -FRBBS$ MASK FOR FRBBS FIELD
LOAD A5,B4,FRBBS# (X5)=FRBBS[PREBUF] WORD
LX0 FRBBS?-FRBBS$+1 SHIFT TO APPR POS IN WORD
BX7 X0*X5 REST OF WORD MINUS FRBBS FD
BX5 -X0*X5 GET FRBBS FIELD FROM WORD FRBBS[PREBUF]
LOAD A3,B5,FRBBS# (X3)=FRBBS[FOBUF] WORD
BX6 -X0*X3 GET FRBBS FIELD FROM WORD FRBBS[FOBUF]
IX5 X5+X1 ADD FRBBS[PREBUF] AND FRBBS[BUFWA]
IX5 X5+X6 ADD RESULT AND FRBBS[FOBUF]
BX7 X7+X5 INTEGRATE THE RESULTING FRBWD[PREBUF]
SB7 X3 TEMP1=FRBFBFP[FOBUF]
MX0 -FRBFBFP$ MASK FOR FRBFBFP FD
BX7 X0*X7 FRBFBFP[PREBUF] WORD MINUS FP FD
SX0 B7 (X0)=FBFBFP[FOBUF]
LOAD A5,B7,FRBFBBP# (X5)=FRBFBBP[FRBFBFP[FOBUF]] WORD
BX7 X7+X0 (X7)=FRBFBFP[FOBUF]+ORIGINAL FRBWPLPREBUF]
MX4 -FRBFBBP$ MASK FOR FRBFBBP
STORE A7,B4,FRBWD# (X7)=FRBWD[PREBUF]
LX4 FRBFBBP?-FRBFBBP$+1 SHIFT TO APPR POS IN WORD
SX3 B4 (X3)=PREBUF VALUE
BX6 X4*X5 (X6)=FRBWD[FRBFBFP[FOBUF]] MINUS FRBFBBP FD
LX3 FRBFBBP?-FRBFBBP$+1 SHIFT FRBFBBP FD TO RIGHT POS
BX6 X6+X3 FRBFBBP[FRBFBFP[FOBUF]]=PREBUF
SA6 A5 STORE FRBFBBP[FRBFBFP[FOBUF]] TO CM
SX7 B3-1 (X7)=FRENOFB-1
SA7 FRETAB+FRENOFB# STORE FRENOFB TO CM
EQ MEXIT
**
*
* CASE 2 RELEASE BLK FOR, CONTIGUOUS BLK WITH PECEEDING BLK ONLY
MRLSZ MX0 -FRBBS$ MASK FOR FRBBS FIELD
LOAD A5,B4,FRBBS# (X5)=FRBBS[PREBUF] WORD
LX0 FRBBS?-FRBBS$+1 SHIFT TO APPR POS IN WORD
BX4 -X0*X5 (X4)=FRBBS[PREBUF] ONLY
BX5 X0*X5 (X5)=FRBBS[PREBUF] WORD MINUS FRBBS[PREBUF]
IX7 X4+X1 (X7)=FRBBS[PREBUF]+FRBBS[BUFWA]
BX7 X7+X5 (X7)=FRBWD[PREBUF] RESULT
SA7 A5 FRBBS[PREBUF]=FRBBS[PREBUF]+FRBBS[BUFWA]
EQ MEXIT
**
*
* CASE 3 RELEASE BLK FORM CONTIGUOUS BLK WITH FOLLOWING BLK ONLY
MRLSY NE B5,B6,MRLSX BRANCH IF FOBUF NE TEMP2
MX0 -FRBBS$ MASK FOR FRBBS FIELD
LX0 FRBBS?-FRBBS$+1 SHIFT TO APPR POS IN WORD
LOAD A3,B5,FRBBS# (X3)=FRBBS[FOBUF] WORD
BX6 -X0*X3 (X6)=FRBBS[FOBUF] ONLY
BX5 X0*X3 (X5)=FRBWD[BUFWA] MINUS FRBBS[BUFWA]
IX6 X6+X1 (X6)=FRBBS[BUFWA]+FRBBS[FOBUF] NOT JUST.
BX6 X6+X5 (X6)=RESULT TO BE STORE IN FRBWD[BUFWA]
SA6 X2 STORE NEW FRBWD[BUFWA] TO CM
SB7 X3 (B7)=FRBFBFP[FOBUF] TEMP1
LOAD A1,B4,FRBFBFP# (X1)=FRBFBFP[PREBUF] WORD
MX7 -FRBFBFP$ MASK FOR FRBFBFP FD
BX7 X7*X1 FRBFBFP[PREBUF] WORD MINUS FP FD
BX7 X7+X2 (X7)=NEW FRBWD[PREBUF], FP SET BUFWA
MX4 -FRBFBBP$ MASK FOR FRBFBBP FIELD
SA7 A1 STORE NEW FRBWD[PREBUF]
LX4 FRBFBBP?-FRBFBBP$+1 SHIFT TO APPR POS IN WORD
LOAD A5,B7,FRBFBBP# (X5)=FRBFBBP[FRBFBFP[FOBUF]] WORD
BX5 X4*X5 FRBWD[FRBFBFP[FOBUF]] MINUS FRBFBBP FIELD
LX2 FRBFBBP?-FRBFBBP$+1 SHIFT TO APPR POS IN WORD
BX6 X5+X2 NEW FRBWD[FRBFBFP[FOBUF]]
SA6 A5 STORE TO CM
EQ MEXIT
**
*
* CASE 4 RELEASE BUFFER DOES NOT FORM CONTIGUOUS BLOCK WITH ANY BLK
MRLSX SX3 B4 (X3)=PREBUF VALUE
LX3 FRBFBBP?-FRBFBBP$+1 SHIFT TO APPR POS IN WORD
BX1 X1+X3 FRBFBBP[BUFWA]=PREBUF
SB3 B3+1 FRENOFB=FRENOFB+1
SX5 B5 (X5)=FOBUF
BX6 X1+X5 FRBFBFP[BUFWA]=FOBUF
STORE A6,B2,FRBWD# (X6)=NEW FRBWD[BUFWA]
MX0 -FRBFBFP$ MASK FOR FRBFBFP FD
LOAD A4,B4,FRBFBFP# (X4)=FRBFBFP[PREBUF] WORD
BX4 X0*X4 FRBFBFP[PREBUF] WORD MINUS FP FD
SX6 B3 (X6)=UPDATED FRENOFB
BX7 X4+X2 FRBFBFP[PREBUF]=BUFWA
SA7 A4 STORE TO CM
SA6 FRETAB+FRENOFB# STORE TO CM
MX0 -FRBFBBP$ MASK FOR FRBFBBP
LOAD A5,B5,FRBFBBP# (X5)=FRBFBBP[FOBUF] WORD
LX0 FRBFBBP?-FRBFBBP$+1 SHIFT TO APPR POS IN WORD
BX5 X0*X5 REST OF WORD MINUS FRBFBBP[FOBUF] FD
LX2 FRBFBBP?-FRBFBBP$+1 SHIFT TO APPR POS IN WORD
BX7 X5+X2 FRBFBBP[FOBUF]=BUFWA
SA7 A5 STORE RESULT TO CM
MEXIT BSS 0
IFEQ BFSC,1,1
RJ BFSCAN
EQ MRELSX EXIT
IFEQ DEBUG,1,2
MSGDR VFD 60/MSGBLK
BSSZ 1
XMRELS DATA L*MRELS*
TEMP BSS 1
MSGBLK DATA L*MRELS BUFFER MANAGEMENT ERROR*
END