User Tools

Site Tools


cdc:nos2.source:nam5871:mgbgclt

MGBGCLT

Table Of Contents

  • [00010] PRGM MGBGCLT
  • [00081] PROC MAJPTR
  • [00082] PROC MACQ
  • [00083] PROC MCLRIL
  • [00084] PROC MRELS
  • [00085] PROC MSETIL
  • [00086] PROC OCFL
  • [00087] PROC OMOVE
  • [00088] PROC OTIME
  • [00089] PROC XTRACE

Source Code

MGBGCLT.txt
  1. *DECK MGBGCLT
  2. USETEXT NIPDEF
  3. USETEXT AT
  4. USETEXT FREETAB
  5. USETEXT PARAMP
  6. USETEXT PT
  7. USETEXT STATTAB
  8. USETEXT STATTB2
  9. USETEXT TNT
  10. PRGM MGBGCLT; # GARBAGE COLLECTION
  11.   MOVE BUFFER IN USE TO LOWER ADDRESSES #
  12.  
  13. STARTIMS;
  14. #
  15. *1DC MGBGCLT
  16. * 1. PROC NAME AUTHOR DATE
  17. * MGBGCLT Y. HSIEH 77/02/10
  18. *
  19. * 2. FUNCTIONAL DESCRIPTION.
  20. * THIS ROUTINE IS RESPONSIBLE FOR GARBAGE COLLECTING.
  21. * WHEN IT IS CALLED BY XEXEC WHEN THE NUMBER OF BUFFERS AND
  22. * SIZE OF FREE BUFFER CHAIN EXCEED THE LIMITS DEFINED BY
  23. * INSTALLATION.
  24. *
  25. * 3. METHOD USED.
  26. * SCAN ALL THE FREE BUFFERS IN FREE CHAIN.
  27. * IF FOUND MOVABLE BUFFERS FOLLOWED IT, THEN MOVE ALL THE
  28. * MOVABLE BUFFERS TO A LARGE ENOUGH FREE BUFFER AT LOWER
  29. * ADDRESS BY CALLING COMPASS ROUTINE OMOVE.
  30. * AFTER MOVE, CALL MAJPTR TO ADJUST POINTERS, AND CALL MRELS
  31. * TO RELEASE UNUSED SPACE TO FREE CHAIN.
  32. * AFTER ALL THE FREE BUFFERS HAVE BEEN CHECKED,
  33. * SEE WHETHER THE LAST BUFFER SIZE EXCEEDS 1000B WORDS, IF SO
  34. * RELEASE ALL THE CORE BUT 500B WORDS TO SYSTEM.
  35. *
  36. * 4. ENTRY PARAMETERS.
  37. * FRENOFB INITIAL NUMBER OF EMPTY BUFFERS
  38. * PARAMP1 = 0 NO PRU BUFFER SHOULD BE MOVED.
  39. * = 1 PRU BUFFER IS ALLOWABLE FOR MOVING.
  40. *
  41. * 5. EXIT PARAMETERS.
  42. * MTIM =0,INITIALIZES ELAPSED TIME FOR REDUCING FL
  43. *
  44. * 6. COMDECKS CALLED AND SYMPL TEXTS USED.
  45. * FREETAB NIPDEF OSIZE STATTB2
  46. * AT APPLICATION TABLE
  47. * STATTAB STATISTICS TABLE
  48. * TNT TERMINAL NODE TABLE
  49. *
  50. * 7. ROUTINES CALLED.
  51. * MACQ GET FREE BUFFER
  52. * MAJPTR ADJUST BUFFER POINTERS AFTER MOVE
  53. * MRELS RELEASE BLOCK TO FREE POOL
  54. * OCFL MAKE MEMORY REQUEST TO SYSTEM
  55. * OMOVE COMPASS FAST MEMORY MOVE ROUTINE
  56. * OTIME GET SYSTEM RTIME
  57. * XTRACE RECORD CALL
  58. * MCLRIL CLEAR INTERLOCK
  59. * MSETIL REQUEST INTERLOCK
  60. *
  61. * 8. DAYFILE MESSAGES. NONE
  62. *
  63. * W A R N I N G - THE TOTAL SIZE OF THE GARBAGE COLLECTION
  64. * ROUTINES (MAJPTR, MCHKPTR, MGBGCLT, AND
  65. * MDRPTR) WITH THE DELAY OPTION TURNED ON
  66. * CAN NOT EXCEED THE PRIMARY AND SECONDARY
  67. *CALL OSIZE
  68. *
  69. * THIS OVERLAY IS CALLED BY XEXEC.
  70. *
  71.  #
  72. STOPIMS;
  73. #
  74.  PARAMETERS
  75.   NONE
  76. #
  77. #
  78.  EXTERNAL VARIABLES
  79. #
  80. XREF BEGIN
  81. PROC MAJPTR; # ADJUST BUFFER PTRS AFTER MOVE #
  82. PROC MACQ; # GET FREE BUFFER #
  83. PROC MCLRIL; # CLEAR INTERLOCK #
  84. PROC MRELS; # RETURN BLOCK TO FREE POOL #
  85. PROC MSETIL; # REQUEST INTERLOCK #
  86. PROC OCFL; # MAKE MEMORY REQUEST TO OP SYSTEM #
  87. PROC OMOVE; # COMPASS FAST MEMORY MOVE ROUTINE #
  88. PROC OTIME; # GET SYSTEM RTIME #
  89. PROC XTRACE; # RECORD CALL #
  90. LABEL RJMAIN; # RETURN ADDRESS IN OVLCALL #
  91. END
  92. #
  93.  LOCAL VARIABLES
  94. #
  95. ITEM FLAG B; # TRUE IF A FUNCTION LIST EXISTS #
  96. ITEM FREBUF; # LOCATION OF CURRENT FREE BUFFER #
  97. ITEM INITNOB; # INITIAL NO OF EMPTY BUFFERS #
  98. ITEM INTERLOCK B; # TRUE IF INTERLOCK PIP REQUIRED #
  99. ITEM RELBUF; # FWA OF BUFFER RELEASE TO FREE CHAIN #
  100. ITEM TEMP; # TEMPORARY WORD #
  101. ITEM TEMP1; # TEMPORARY WORD #
  102. DEF RTBUF #2#; # REDUCE FL IF GQ 640 WORDS FOR RTBUF SEC#
  103.  
  104. CONTROL IFEQ STAT,1;
  105. ARRAY STIME P(1); # RTIME BUFFER FOR STARTING TIME #
  106. BEGIN
  107. ITEM SSECS U(0,00,24); # STARTING TIME IN SECONDS #
  108. ITEM SMILS U(0,24,36); # STARTING TIME IN MILLESECONDS #
  109. END
  110. ARRAY ETIME P(1); # RTIME BUFFER FOR ENDING TIME #
  111. BEGIN
  112. ITEM EMILS U(0,24,36); # ENDING TIME IN MILLESECONDS #
  113. END
  114.  
  115. ITEM STTEMP; # TEMPORARY STATISTICS VARIABLE #
  116. CONTROL FI;
  117.  
  118. #**********************************************************************#
  119. BEGIN
  120. CONTROL IFEQ DEBUG,1;
  121. XTRACE("MGBGC") ;
  122. CONTROL FI;
  123.  
  124. CONTROL IFEQ STAT,1; # STATISTICS ON #
  125. #
  126.   DETERMINE AVG NO OF EMPTY BUFFERS AND WORDS
  127. #
  128. OTIME(STIME); # GET CURRENT RTIME #
  129. TEMP = SSECS[0] - TIMEGBG; # ELAPSED TIME SINCE LAST CALL #
  130. ST$FWT = ST$FWT + TEMP*FRESFB[0]; # TIME * NO OF FREE WORDS #
  131. ST$FBT = ST$FBT + TEMP*FRENOFB[0]; # TIME * NO OF FREE BUFS #
  132. TIMEGBG = SSECS[0]; # RESET TIMER FOR NEXT CALL #
  133. #
  134.   STORE INITIAL NO OF FREE WORDS AND BUFFERS
  135. #
  136. INITNOB = FRENOFB[0]; # INITIAL NO OF EMPTY BUFFERS #
  137. CONTROL FI;
  138.  
  139.  
  140. #
  141.  STEP 1 SCAN FREE CHAIN FOR FOLLOWING MOVABLE BUFFERS
  142. #
  143.  
  144. P<FREEBUF> = 0;
  145. REDUCEFL = 0;
  146.  
  147. FOR FREBUF = LOC(FREFBFP[0])
  148. DO
  149.  
  150. BEGIN
  151. FREBUF = FRBFBFP[FREBUF]; # LOCATION OF NEXT FREE BUFFER #
  152.  
  153. NEXT:
  154. IF FREBUF NQ LOC(FREFBFP[0]) # REACH END OF FREE CHAIN #
  155. THEN
  156.  
  157. BEGIN
  158. MOLD = FREBUF + FRBBS[FREBUF]; # FWA OF BUF FOLLOW FREE BUF #
  159. IF MOLD LS CTLSLWA
  160. THEN
  161. BEGIN
  162. MSIZE = 0; # SIZE OF MOVABLE BLOCK #
  163. FLAG = FALSE; # PRESET TO NO FUNCTION LIST #
  164. # BUFFER WITHIN MOVABLE BLOCK #
  165.  
  166. INTERLOCK = FALSE; # NO INTERLOCK REQUIRED #
  167. FOR TEMP = MOLD WHILE TEMP LS CTLSLWA
  168. DO
  169. BEGIN
  170. IF FRBMV[TEMP]
  171. OR FRBID[TEMP] EQ 0
  172. OR (FRBID[TEMP] EQ PRUBIDVALUE AND
  173. NOT PRUMOVE)
  174. THEN
  175. BEGIN
  176. IF MSIZE EQ 0 # NO MOVABLE BUF FOUND #
  177. THEN
  178. TEST FREBUF;
  179. ELSE
  180. GOTO FIND;
  181. END
  182.  
  183. ELSE
  184. BEGIN
  185. MSIZE = MSIZE + FRBBS[TEMP];# INCREASE MOVE SIZE #
  186. IF FRBID[TEMP] EQ FLIDVALUE
  187. THEN
  188. FLAG = TRUE; # FUNCTION LIST BUFFER EXISTS #
  189. IF FRBID[TEMP] EQ TNTIDVALUE OR
  190. FRBID[TEMP] EQ NCNTIDVALUE OR
  191. FRBID[TEMP] EQ PCNBIDVALUE OR
  192. FRBID[TEMP] EQ PRUBIDVALUE OR
  193. FRBID[0] EQ PRUSPECID OR
  194. FRBID[TEMP] EQ LLCBIDVALUE
  195. THEN
  196. INTERLOCK = TRUE; # INTERLOCK REQUIRED FOR MOVE #
  197. TEMP = TEMP + FRBBS[TEMP]; # FWA OF NEXT BUFFER #
  198. END
  199.  
  200. END
  201.  
  202. #
  203.  STEP 2 LOOK FOR A BIG ENOUGH FREE BLK TO MOVE TO
  204. #
  205.  
  206. FIND:
  207. FOR MNEW = LOC(FREFBFP[0])
  208. DO
  209. BEGIN
  210.  
  211. MNEW = FRBFBFP[MNEW];
  212. IF MNEW EQ FREBUF OR FRBBS[MNEW] GQ MSIZE
  213. THEN
  214. GOTO FOUND;
  215.  
  216. END
  217.  
  218. FOUND:
  219. IF MNEW EQ FREBUF # REACHED CURRENT FREE BUFFER #
  220. AND (( TEMP LS CTLSLWA # NEXT BUFFER EXISTS #
  221. AND FRBMV[TEMP] ) # AND IS NON-MOVABLE #
  222. OR FLAG ) # NEXT BUFFER IS A FUNCTION LIST BUFFER #
  223. THEN # OMIT THIS FRUITLESS MOVE #
  224. TEST FREBUF;
  225.  
  226. #
  227.  STEP 3 UPDATE FREETAB INFO AND DELINK FREE BLK FOUND
  228.   MOVE BLK TO IT AND RELEASE EXTRA SPACE
  229. #
  230. IF MNEW NQ FREBUF
  231. THEN
  232. MACQ(MSIZE, MNEW, FALSE);
  233. ELSE
  234. BEGIN
  235. TEMP = FRBBS[MNEW];
  236. MACQ(TEMP, MNEW, FALSE);
  237. END
  238.  
  239. CONTROL IFEQ STAT,1; # STATISTICS ON #
  240. ST$GBWM = ST$GBWM + MSIZE; # INCR CNT OF NO OF WDS MOVED #
  241. CONTROL FI;
  242.  
  243. IF INTERLOCK # BUF USED BY PIP TO MOVE #
  244. THEN
  245. MSETIL(0); # INTERLOCK ALL PIP-S #
  246. OMOVE; # MEMORY MOVE #
  247.  
  248. IF MNEW NQ FREBUF # MOVE TO LOWER ADDR FREE BUF #
  249. THEN
  250. BEGIN
  251. RELBUF = MOLD;
  252. FRBBS[RELBUF] = MSIZE;
  253. END
  254. ELSE
  255. BEGIN
  256. RELBUF = MNEW + MSIZE;
  257. FRBBS[RELBUF] = TEMP;
  258. FREBUF = RELBUF;
  259. END
  260.  
  261. MRELS(RELBUF);
  262. MAJPTR; # ADJUST BUFFER POINTERS #
  263. GOTO NEXT; # CHECK NEXT FREE BUFFER #
  264. END
  265.  
  266. END
  267.  
  268. GOTO DONE; # EXIT FROM LOOP #
  269. END
  270.  
  271. #
  272.  STEP 4 ALL MOVE DONE, CHECK SIZE OF LAST FREE BLOCK
  273.   IF MORE THAN 2*RSBUF THEN RELEASE RSBUF TO SYSTEM
  274. #
  275.  
  276. DONE:
  277. P<AT> = PTAT[0]; # RESET AT BASED ARRAY POINTER #
  278. P<TNT> = PTTNT[0]; # RESET TNT BASED ARRAY POINTER#
  279. MCLRIL; # CLEAR NIP/PIP INTERLOCK #
  280. CONTROL IFEQ STAT,1; # STATISTICS ON #
  281. #
  282.   RECORD ANY CHANGES IN NO OF FREE BUFFERS OR WORDS
  283. #
  284. ST$GBGC = ST$GBGC + INITNOB-FRENOFB[0];
  285. OTIME(ETIME); # GET SYSTEM TIME AFTER GARBAGE COLLECTION#
  286. STTEMP = EMILS[0] - SMILS[0]; # TIME SPENT IN MOVING BUFFERS #
  287. ST$TMG = ST$TMG + STTEMP; # TOTAL TIME SPENT MOVING BUFFERS #
  288. IF ST$LMG LS STTEMP
  289. THEN # FOUND LARGER TIME INTERVAL MOVING BUFFER#
  290. BEGIN
  291. ST$LMG = STTEMP; # NEW LARGEST TIME INTERVAL #
  292. END
  293.  
  294. CONTROL FI;
  295.  
  296. IF FREFBBP + FRBBS[FREFBBP] EQ CTLSLWA # NO NONMOVABLE BK AT END #
  297. THEN
  298. BEGIN
  299. HRL = HRLV3; # ASSUME REGULATION LEVEL 3 #
  300. IF MAXFL - FREFBBP LS BUFLV3
  301. THEN # CRITICAL BUFFER SHORTAGE #
  302. BEGIN
  303. HRL = HRLV2; # BUFFER REGULATION LEVEL 0 #
  304. IF MAXFL - FREFBBP LS BUFLV2
  305. THEN # SEVERE BUFFER SHORTAGE #
  306. BEGIN
  307. HRL = HRLV1; # BUFFER REGULATION LEVEL 1 #
  308. IF MAXFL - FREFBBP LS BUFLV1
  309. THEN # MODERATE BUFFER SHORTAGE #
  310. BEGIN
  311. HRL = HRLV0; # BUFFER REGULATION LEVEL 2 #
  312. END
  313. END
  314. END
  315.  
  316.  
  317. IF FRBBS[FREFBBP] GQ 2*RSBUF # LAST FREE BLK TOO BIG #
  318. THEN
  319. BEGIN
  320.  
  321. CONTROL IFEQ DELAY,1; # ASSEMBLE ONLY IF DELAY OPTION#
  322. IF MTIM NQ 0 AND RTSECS-MTIM GQ RTBUF # EXCEED ELAPSE TIM#
  323. THEN
  324. BEGIN
  325. MTIM = 0; # RESET ELAPS TIM FOR REDUCE FL#
  326. CONTROL FI;
  327.  
  328.  
  329. CONTROL IFEQ STAT,1; # STATISTICS ON #
  330. ST$FLT = ST$FLT + (SSECS[0] - TIMECFL) * (CTLSLWA/64);
  331. TIMECFL = SSECS[0]; # RESET TIMER FOR NEXT OCFL CALL #
  332. CONTROL FI;
  333.  
  334. TEMP1 = (FREFBBP[0]+RSBUF+63)/64*64; # NEW CTLSLWA #
  335. TEMP = CTLSLWA - TEMP1; # EXTRA SPACE TO RELEASE #
  336. CTLSLWA = TEMP1;
  337. CONTROL IFEQ STAT,1; # STATISTICS ON #
  338. ST$FLX = ST$FLX + 1; # INCR NO OF TIMES FL DECREASED #
  339. ST$FLWX = ST$FLWX + TEMP; # INCR TOTAL OF WDS DECREASED #
  340. CONTROL FI;
  341. OCFL(CTLSLWA); # CHANGE PROGRAM LENGTH #
  342.  
  343. FREMFL = FALSE; # CLEAR NIP REACH MAX FL FLAG #
  344. FRESFB = FRESFB - TEMP; # REDUCE FREE CHAIN SIZE #
  345. FRBBS[FREFBBP] = FRBBS[FREFBBP] - TEMP; # LAST FREE BUF SZ#
  346.  
  347. CONTROL IFEQ DELAY,1;
  348. END
  349.  
  350. ELSE
  351. BEGIN
  352. IF MTIM EQ 0
  353. THEN
  354. BEGIN
  355. MTIM = RTSECS; # SET ELAPSE TIME FOR REDUCE FL#
  356. END
  357.  
  358. END
  359.  
  360. GOTO RJMAIN;
  361. CONTROL FI;
  362.  
  363. END
  364.  
  365. END
  366.  
  367. CONTROL IFEQ DELAY,1;
  368. MTIM = 0; # RESET ELAPS TIM FOR REDUCE FL#
  369. CONTROL FI;
  370.  
  371. GOTO RJMAIN;
  372.  
  373. END
  374. TERM
cdc/nos2.source/nam5871/mgbgclt.txt ยท Last modified: 2023/08/05 17:22 by Site Administrator