home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a012 / 1.ddi / OVLRLD2.TXT < prev    next >
Encoding:
Text File  |  1991-05-01  |  7.7 KB  |  167 lines

  1.               5.0 FOCUS: Memory Management, Overlay Reloading #2
  2.                                By Roger Donnay
  3.  
  4. Introduction
  5.  
  6. In the December 1990 Aquarium, I discussed the advantages of using
  7. reloadable overlays to reduce the memory overhead of your application.
  8. Before reading this article, I recommend that you refresh your memory by
  9. referring to the aforementioned article and get re-acquainted with the
  10. RELOAD command and MODULE command, which are undocumented .RTLINK
  11. features.
  12.  
  13. In the following examples, I will show you how to use the RELOADABLE
  14. OVERLAY feature of .RTLINK to overlay sections of your third-party
  15. libraries.  I will specifically address the dGE and FUNCKy libraries,
  16. which are primarily written in C and Assembler.
  17.  
  18. Most third-party libraries are written in C, Assembler, and/or
  19. Clipper. It is important when using a third-party library that you
  20. know which modules are written in which language because this
  21. information will make it much easier for you to develop an overlay
  22. strategy.  Third-party documentation usually does not include this
  23. information, so you will be required to figure it out for yourself.
  24. Getting this information is not really very difficult, but it may
  25. require you to invest a bit of time. For example, it took me nearly
  26. five hours to work out an overlay strategy for the FUNCKy library, but
  27. now that the work is done, the same overlay segments can be used in
  28. all FUNCKy applications.
  29.  
  30.  
  31. Determining the "Module" Names in a Library
  32.  
  33. Every .OBJect file placed into a library is also assigned a module name.
  34. This module name is stored in the "COMMENT" record of the object in the
  35. library.  The "module" name of an object is assigned by the compiler of
  36. the object and is usually given the name of the original source code.
  37. For example, let's say we want to place the FUNCKy FINDATTR() function
  38. into an overlay.  First, we must figure out what "module" name was
  39. assigned to the FINDATTR() function.  There are library manager utility
  40. programs which can help you figure this out, but I'm going to show you
  41. how to do it simply with your linker. During VERBOSE linking with RTLINK
  42. or BLINKER, the module name of each object being linked into the program
  43. is displayed on the screen as follows:
  44.  
  45.    FUNCKY50.LIB(C_MAXCHO)         <- Clipper code
  46.    FUNCKY50.LIB(C_PUTKEY)         <- Clipper code
  47.    FUNCKY15.LIB(findattr.C)       <- "C" code
  48.    FUNCKY15.LIB(finddate.C)       <- "C" code
  49.    FUNCKY15.LIB(findfirs.C)       <- "C" code
  50.    FUNCKY15.LIB(chrfound.ASM)     <- "Assembly" code
  51.    FUNCKY15.LIB(strcente.ASM)     <- "Assembly" code
  52.  
  53. You must make sure that you insert the command VERBOSE into your link
  54. script file to insure that this information is displayed.  Next, when
  55. you perform the link, make sure to route the dislay output to a file
  56. so you can have the information in text file format:
  57.  
  58.    RTLINK @MYPROG > MYPROG.TXT
  59.  
  60. MYPROG.TXT will contain the complete list of modules linked into your
  61. program.  Now we must use this information to develop an overlay
  62. strategy.  The name of each module linked into the program (shown in
  63. parentheses) must be referred to exactly as spelled.  For example,
  64. to place the function FINDATTR() into an overlay, we must first
  65. determine the module name which would contain the FINDATTR() function.
  66. Fortunately, the FUNCKY15 library uses the same prefix name as the
  67. actual function, so in perusing the list of linked objects in MYPROG.TXT
  68. we find a module named "findattr.c".  To place this module in an overlay
  69. section, simply use the command:
  70.  
  71.    SECTION MODULE findattr.c
  72.  
  73. When placing modules into overlays, you must use extreme care to not
  74. overlay functions which are either called by interrupts or recursively.
  75. Code which is called by interrupts is called by a direct vector rather
  76. than a real address.  This can cause your computer to lock up if the
  77. code segment is not currently in memory.  Code which is called
  78. recursively would be something like special string handling routines
  79. that might be called from within a DO..WHILE loop.  If this function
  80. were placed in an overlay, you may experience considerably slower
  81. performance and/or disk access.
  82.  
  83. Many third-party library developers now distribute their product in two
  84. libraries: a resident library and an overlayable library. Most
  85. of the work has already been done for you in determining which modules
  86. can be overlayed.  If the module is part of the resident library, do not
  87. make any attempt to try to overlay it, or you will certainly experience
  88. run-time problems.  Also, do not overlay "Clipper code" because this
  89. code is automatically overlayed into "dynamic-pages" by Rtlink.
  90.  
  91.  
  92. Overlaying the dGE Library
  93.  
  94. dGE consists of a set of graphics functions and screen-drivers. dGE has
  95. different screen-drivers for CGA, EGA, VGA, etc.; yet, this overlay
  96. structure allows all the screen-drivers to be linked into the
  97. application without using any more memory.  The rest of the library is
  98. written in "C" and is broken down into 10 modules, each holding a set of
  99. functions. The screen drivers CANNOT be placed into the same section as
  100. the functions because the currently selected driver cannot be swapped
  101. out of memory at runtime.  The screen driver segment mixes code and data
  102. so if it were swapped out, you would lose your current bit-mapped
  103. screen.
  104.  
  105. The dGE library was one of the easiest overlay structures to develop.
  106. This one took me less than an hour and appears to work flawlessly. The
  107. link script file shown in the accompanying source code file is used to
  108. create the dGE demonstration program.  Please note the use of another
  109. undocumented feature of RTLINK in this script file:
  110.  
  111.   @ CLIPPER.LNK
  112.  
  113. The "@" command in an RTLINK script file is similar to the "#include"
  114. command in your Clipper source.  In this case, we included the overlay
  115. script for the Clipper libraries (editor's note: please refer to
  116. Roger's article in the 12/90 Aquarium for this script).
  117.  
  118.  
  119. Overlaying the FUNCKy Library
  120.  
  121. Developing an overlay strategy for FUNCKy was a larger project simply
  122. due to the large number of functions in this library.  Actually,
  123. determining the name of each module was also a bit of a struggle
  124. because the module names don't always correspond to the function
  125. names.
  126.  
  127. First, I needed to build a .MAP of the FUCNKy libraries using a
  128. library manager such as LIB.EXE which comes with all the Microsoft
  129. languages.  This will scan a library and produce the following output:
  130.  
  131. FUNPROTECT........funprote          FUNstack..........funstack
  132. FWRITE............fwrite            FWRITEBYTE........fwriteby
  133. FWRITEINT.........fwritein          FWRITELINE........fwriteli
  134.  
  135. This kind of map only gives you the "pseudo module name" because it
  136. does not include the source code extension (".C" or ".ASM").  To get
  137. the full module name you must get it during the "verbose" link cycle
  138. as shown earlier in this article.
  139.  
  140. Link script file #2 in the accompanying source code file is used to
  141. create the VIEW.EXE demonstration program.  You will get a large
  142. number of "warnings" when using this script, because the VIEW.PRG
  143. program does not call all of the modules we have asked RTLINK to
  144. overlay.  You can eliminate the warnings by removing the "warned"
  145. modules from the overlay segments.
  146.  
  147.  
  148. Summary
  149.  
  150. Please review these link script files carefully.  They should help you
  151. in designing strategies for overlaying third-party libraries with
  152. .RTLINK and Clipper 5.0.
  153.  
  154.  
  155. About the Author
  156.  
  157. Roger Donnay is the developer of the dCLIP development platform/runtime
  158. system for Clipper, and the application libraries SOFT.CLIP and TIME-TRAK.
  159. He can be reached at via the Aquarium Message Center, or c/o:
  160.  
  161. DONNAY Software Designs
  162. 1880 Park Newport, #104
  163. Newport Beach, CA 92660
  164. Tel: 714-721-6720
  165. Fax: 714-721-9495
  166. Compuserve: 73227,1225
  167.