User Tools

Site Tools


cdc:nos2.source:nam5871:exgetsb

EXGETSB

Table Of Contents

Source Code

EXGETSB.txt
  1. *DECK EXGETSB
  2. PROC GETTSB ( (SIZE),(IDENT), TFWA );
  3. BEGIN # GETTSB #
  4. *IF DEF,IMS
  5. #
  6. **
  7. *
  8. * 1. PROC NAME AUTHOR DATE
  9. * GETTSB M. D. PICKARD 76/11/15
  10. *
  11. * 2. FUNCTIONAL DESCRIPTION
  12. * GETTSB WILL FIND A FREE TSB OF THE REQUESTED SIZE. THE
  13. * TSB HEADER IS WRITTEN INDICATING THAT THE TSB IS ASSIGNED,
  14. * FIXED POSITION AND ASSOCIATED TO THE SPECIFIED IDENT.
  15. * THE ADDRESS OF THE TSB IS RETURNED TO THE CALLER
  16. *
  17. * 3. METHOD USED
  18. * IF A FREE TSB EXISTS THAT IS GREATER OR EQUAL IN SIZE TO THE
  19. * REQUEST SIZE, A TSB IS CHOSEN TO SATISFY THE REQUEST.
  20. * IF A FREE TSB THAT WILL SATISFY THE REQUEST DOES NOT EXIST,
  21. * THEN AN ATTEMPT IS MADE TO MOVE ASSIGNED VARIABLE POSITION
  22. * BLOCKS UNTIL A CONTIGUOUS FREE AREA DOES EXIST THAT WILL
  23. * SATISFY THE REQUEST.
  24. * IF THE LATTER FAILS MORE FIELD LENGTH IS REQUESTED TO CREATE
  25. * A FREE TSB THAT WILL SATISFY THE REQUEST.
  26. * WHEN A TSB IS FOUND THAT SATISFIES THE REQUEST, THE HEADER
  27. * IS BUILT AND THE ADDRESS RETURNED TO THE CALLER.
  28. *
  29. * 4. ENTRY PARAMETERS
  30. * A. FORMAL PARAMETERS
  31. * SIZE NUMBER OF WORDS IN REQUESTED TSB
  32. * MUST BE GREATER THAN ZERO AND LESS THAN
  33. * MAXTSBL
  34. *
  35. * IDENT IDENTIFIER FOR BLOCK, PLACED IN HEADER
  36. * MUST BE GREATER THAN ZERO AND LESS THAN
  37. * MAXTSBI
  38. * B. TSBMGR GLOBAL PARAMETERS
  39. * BIGFREE BIGGEST AVAILABLE FREE TSB
  40. * CTSBLWA CURRENT TSB AREA LAST WORD ADDRESS
  41. * FFFWA FIRST FREE TSB FIRST WORD ADDRESS
  42. *
  43. * 5. EXIT PARAMETERS
  44. * TFWA TSB FIRST WORD ADDRESS RETURNED TO CALLER
  45. * TFWA WILL BE ZERO IF REQUEST NOT SATISFIED
  46. *
  47. * 6. COMDECKS CALLED
  48. * TSBBASE TSB MANAGER BASED ARRAY DEFINITIONS
  49. * TSBDATA TSB MANAGER DATA AREA DEFINITIONS
  50. * TSBDEFS TSB MANAGER SYMPL DEFS
  51. *
  52. * 7. ROUTINES CALLED
  53. * FIRSTF GET FWA OF FIRST FREE TSB IN THE TSB AREA
  54. * GETFREE GETS FWA OF NEXT FREE TSB
  55. * MESSAGE ISSUES DAYFILE MESSAGES (MACREL)
  56. * GETBIG GETS SIZE OF BIGGEST FREE TSB
  57. * NEWFREE CREATE NEW FREE TSB WITH EXCESS OF
  58. * NEWLY ASSIGNED TSB
  59. * SQUEEZE CONSOLIDATES FREE SPACE IN TSB AREA AND
  60. * GETS MORE FIELD LENGTH IF NEEDED
  61. *
  62. * 8. DAYFILE MESSAGES
  63. * "TSB LOGICAL ERROR" INFORMATIVE MESSAGE
  64. *
  65. #
  66. *ENDIF
  67. CONTROL NOLIST; # STOPS LIST TSBDEFS,TSBDATA,TSBBASE #
  68. *CALL CYBERDEFS
  69. *CALL TSBDEFS
  70. *CALL TSBBASE
  71. *CALL TSBDATA
  72. CONTROL LIST;
  73. ITEM
  74. SIZE U, # SIZE IN WORDS OF REQUESTED BLOCK #
  75. IDENT U, # IDENTIFIER OF REQUESTED BLOCK #
  76. TFWA U; # ADDRESS OF ASSIGNED BLOCK #
  77. XREF
  78. BEGIN
  79. PROC FIRSTF;
  80. PROC GETBIG;
  81. PROC MESSAGE;
  82. PROC SQUEEZE;
  83. PROC ZERO ;
  84. END
  85. $BEGIN # START DEBUG CODE HERE #
  86. XREF
  87. PROC ABORT;
  88. $END
  89. ITEM
  90. FOUND B, # INDICATES BLOCK IS FOUND #
  91. CFWA U, # CURRENT FREE TSB FWA #
  92. TEMP U; # TEMPORARY UNSIGNED INTEGER #
  93. ARRAY TSBLERR [0:0] P(2); # TSB LOGICAL ERROR DAYFILE MESSAGE #
  94. ITEM
  95. TLERRM C (0,0,17) = [ "TSB LOGICAL ERROR" ],
  96. TLERRZ U (1,42,18) = [ 0 ];
  97. CONTROL EJECT;
  98. PROC NEWFREE ( (FWA),(LENGTH) );
  99. BEGIN # NEWFREE #
  100. *IF DEF,IMS
  101. #
  102. **
  103. *
  104. * 1. PROC NAME AUTHOR DATE
  105. * NEWFREE M. D. PICKARD 76/11/16
  106. *
  107. * 2. FUNCTIONAL DESCRIPTION
  108. * NEWFREE CREATES A NEW FREE TSB AT THE END OF A BLOCK THAT
  109. * IS CHOSEN TO SATISFY A REQUEST WHEN THE BLOCK IS BIGGER THAN
  110. * THE REQUESTED SIZE.
  111. *
  112. * 3. METHOD USED
  113. * CREATE FREE TSB HEADER AT FWA + LENGTH. UPDATE LENGTH FIELD
  114. * ON TSB BEING ASSIGNED AND PREVIOUS BLOCK LENGTH ON TSB AFTER
  115. * THE NEW FREE TSB.
  116. *
  117. * 4. ENTRY PARAMETERS
  118. * A. FORMAL PARAMETERS
  119. * FWA FWA OF CHOSEN TSB
  120. * LENGTH AMOUNT THAT WILL BE ASSIGNED
  121. *
  122. * B. TSBMGR GLOBAL PARAMETERS
  123. * FTSBHDR BASED ARRAY SET AT FWA
  124. *
  125. * 5. EXIT PARAMETERS
  126. * NONE.
  127. *
  128. * 6. COMDECKS CALLED
  129. * NONE.
  130. *
  131. * 7. ROUTINES CALLED
  132. * NONE.
  133. *
  134. * 8. DAYFILE MESSAGES
  135. * NONE.
  136. *
  137. #
  138. *ENDIF
  139. ITEM
  140. FWA U, # FWA OF TSB BEING ASSIGNED #
  141. LENGTH U; # LENGTH OF TSB BEING ASSIGNED #
  142. P<BTSBHDR> = FWA + FTSBL[0]; # SET BUSY HEADER FORMAT AT NEXT TSB#
  143. TEMP = FTSBL[0]; # SAVE OLD LENGTH OF TSB BEING ASSIGNED #
  144. FTSBL[0] = LENGTH; # UPDATE LENGTH OF TSB BEING ASSIGNED #
  145. P<FTSBHDR> = FWA + LENGTH; # SET FREE TSB FORMAT ON NEW TSB #
  146. FBUSY[0] = FALSE; # SET NOT BUSY ON NEW TSB HEADER #
  147. FNOTMOV[0] = FALSE; # ALLOW MOVING OF NEW TSB #
  148. FHDRRSV[0] = 0; # CLEAR RESERVED AREA IN HEADER #
  149. FIDENT[0] = 0; # CLEAR IDENT FIELD #
  150. FPTSBL[0] = LENGTH; # SET NEW TSB"S PREVIOUS TSB LENGTH #
  151. FTSBL[0] = TEMP - LENGTH; # SET LENGTH OF NEW BLOCK #
  152. BPTSBL[0] = FTSBL[0]; # SET NEW PREVIOUS TSB LENGTH ON NEXT TSB #
  153. RETURN;
  154. END # NEWFREE #
  155. CONTROL EJECT;
  156. PROC GETFREE ( (FWA), FFWA );
  157. BEGIN # GETFREE #
  158. *IF DEF,IMS
  159. #
  160. **
  161. *
  162. * 1. PROC NAME AUTHOR DATE
  163. * GETFREE M. D. PICKARD 76/11/16
  164. *
  165. * 2. FUNCTIONAL DESCRIPTION
  166. * GETFREE WILL SEARCH THE TSB AREA FOR THE NEXT FREE TSB
  167. * STARTING AT FWA.
  168. *
  169. * 3. METHOD USED
  170. * START A FWA + LENGTH OF THAT TSB AND SEARCH FOR A NOT BUSY
  171. * TSB UNTIL CTSBLWA. RETURN ADDRESS OF FREE TSB OR CTSBLWA.
  172. *
  173. * 4. ENTRY PARAMETERS
  174. * A. FORMAL PARAMETERS
  175. * FWA FIRST WORD ADDRESS OF TSB TO START SEARCH
  176. * B. TSBMGR GLOBAL PARAMETERS
  177. * CTSBLWA CURRENT TSB AREA LAST WORD ADDRESS
  178. *
  179. * 5. EXIT PARAMETERS
  180. * FFWA ADDRESS OF NEXT FREE TSB OR CTSBLWA
  181. *
  182. * 6. COMDECKS CALLED
  183. * NONE.
  184. *
  185. * 7. ROUTINES CALLED
  186. * NONE.
  187. *
  188. * 8. DAYFILE MESSAGES
  189. * NONE.
  190. *
  191. #
  192. *ENDIF
  193. ITEM
  194. FWA U, # START ADDRESS OF SEARCH #
  195. FFWA U; # NEXT FREE TSB FWA OR CTSBLWA #
  196. P<FTSBHDR> = FWA; # SET FREE HEADER AT START TO GET LENGTH #
  197. P<FTSBHDR> = FWA + FTSBL[0]; # PUT HEADER AT NEXT TSB #
  198. FOR FFWA = LOC(FTSBHDR) WHILE
  199. ( FBUSY[0] AND ( FFWA LQ CTSBLWA)) DO
  200. BEGIN
  201. FFWA = FFWA + FTSBL[0]; # BUMP TO NEXT TSB #
  202. P<FTSBHDR> = FFWA; # RESET HEADER #
  203. END
  204. RETURN;
  205. END # GETFREE #
  206. CONTROL EJECT; # *** GETTSB CODE STARTS HERE *** #
  207. IF FFFWA EQ CTSBLWA
  208. THEN # FIRST FREE IS AT END OF TSB AREA #
  209. SQUEEZE(SIZE,CFWA); # NOTHING IS LEFT TO CONSOLIDATE, GET SOME#
  210. FOUND = FALSE; # INITIALIZE LOOP END CONDITION #
  211. FOR CFWA = FFFWA WHILE (NOT FOUND AND ( CFWA LS CTSBLWA )) DO
  212. BEGIN # FIND A TSB THAT WILL SATISFY THE REQUEST#
  213. IF BIGFREE GQ SIZE
  214. THEN # THERE IS A TSB BIG ENOUGH #
  215. BEGIN # SEARCH ALL FREE TSB"S UNTIL REQUEST IS #
  216. # SATISFIED #
  217. P<FTSBHDR> = CFWA; # SET FREE TSB HEADER FORMAT AT FREE TSB #
  218. IF FTSBL[0] GQ SIZE # CHECK LENGTH OF TSB AGAINST REQ. SIZE #
  219. THEN # THIS FREE TSB IS BIG ENOUGH #
  220. BEGIN
  221. FOUND = TRUE; # END OF LOOP INDICATOR #
  222. IF FTSBL[0] EQ BIGFREE THEN
  223. BIGFREE = 0 ;
  224. TFWA = CFWA; # SET RETURN PARAMETER #
  225. TEMP = SIZE + TSBHDRL; # INSURE AT LEAST ROOM FOR ONE WORD #
  226. # TSB #
  227. IF TEMP LS FTSBL[0] # IS THERE ENOUGH FOR A NEW FREE TSB #
  228. THEN # AT THE END #
  229. NEWFREE(CFWA,SIZE); # CREATE THE NEW FREE TSB #
  230. END
  231. ELSE # GET ADDRESS OF NEXT FREE TSB #
  232. GETFREE(CFWA,CFWA); # GET NEXT FREE TSB #
  233. END
  234. ELSE # SQUEEZE FREE TSB"S TOGETHER OR #
  235. SQUEEZE(SIZE,CFWA); # GET FL TO SATISFY REQUEST #
  236. END
  237. IF FOUND
  238. THEN # BUILD HEADER FOR ASSIGNED TSB #
  239. BEGIN
  240. P<BTSBHDR> = TFWA; # POINT BUSY HEADER FOR CHOSEN FREE TSB #
  241. BBUSY[0] = TRUE; # SET ASSIGNED (BUSY) FLAG #
  242. BNOTMOV[0] = TRUE; # SET FIXED POSITION FLAG #
  243. BHDRRSV[0] = 0; # CLEAR RESERVED AREA #
  244. BIDENT[0] = IDENT; # PUT IDENTIFIER IN HEADER #
  245. SIZE = ( TFWA + TSBHDRL ) - TSBFWA; # USE SIZE AS TEMPORARY #
  246. ZERO(LOC(TSBAREA[SIZE]) ,BTSBL[0]-TSBHDRL );# CLEAR AREA #
  247. FIRSTF;
  248. IF BIGFREE EQ 0 THEN # RE-ESTAB BIGFREE IF USED #
  249. GETBIG ;
  250. END
  251. ELSE # LOGICAL ERROR IN TSB STRUCTURE #
  252. BEGIN
  253. TFWA = 0; # SET ERROR RETURN FLAG #
  254. MESSAGE(TSBLERR,3); # ISSUE LOCAL DAYFILE MESSAGE #
  255. $BEGIN
  256. ABORT; # ***** DEBUG MODE ABORT ***** #
  257. $END
  258. END
  259. RETURN;
  260. END TERM # GETTSB #
cdc/nos2.source/nam5871/exgetsb.txt ยท Last modified: 2023/08/05 17:22 by Site Administrator