home *** CD-ROM | disk | FTP | other *** search
/ APDL Public Domain 1 / APDL_PD1A.iso / program / vmm / !VMM / !Help < prev    next >
Encoding:
Text File  |  1992-03-31  |  7.0 KB  |  209 lines

  1. Help on the Virtual Memory Manager Module
  2. ==========================================
  3.  
  4. This module contains a number of SWI's that allow your programs to use more
  5. memory than is currently available. This is done by using Virtual Memory
  6. (VM). VM is a discfile. A small portion of your computer's memory (RMA) is
  7. used to load a part of this VM-discfile. Every time you wish to access
  8. another part of this VM, the appropriate section of the discfile is loaded.
  9. Thus, enabling you to use, say, 16Mb on a 1Mb machine. At this moment
  10. applications for RISCOS do not know about this VirtualMemoryManager (VMM).
  11. So, at this moment you can only include it into your own applications.
  12. Hopefully, in the (near) future other companies will incorporate this idea
  13. into their own applications. Enhancing your systems capacities beyond your
  14. wildest dreams...
  15.  
  16. The program VVMModDemo demonstrates the use of the module. Use it by starting
  17. it from the *-prompt. If you want to see it working in a multi-tasking
  18. environment then you should open a Task window and run it from there. The
  19. reason why the demo itself isn't multi-tasking is, so the functioning of the
  20. program is not obscured by the parts of the program that supply the
  21. multi-tasking abilities.
  22.  
  23.  
  24. The following SWI's are supplied:
  25.  
  26.  
  27.  
  28. **** SWI VirtualMemory_AdviseSwapSize
  29.  
  30. On Entry:
  31. =========
  32.  
  33. -
  34.  
  35. On Exit:
  36. ========
  37.                                                                        
  38. R0      Advised amount of bytes
  39. R1-R7   Preserved
  40.  
  41. Returns the advised amount of bytes to pass to SWI VirtualMemory_Create as
  42. the swapmemory size. The algorithm used takes into account the
  43. system's total memory and the system's free memory (RMA's largest block and
  44. the free pool). From this the advised amount is calculated. Preferably you should not deviate from this.
  45.  
  46.  
  47. **** SWI VirtualMemory_Create
  48.  
  49. This call initialises the amount of virtual memory that you need.
  50.  
  51. On Entry:
  52. ========= 
  53.  
  54. R0          is the amount of 'real' memory in which the virtual memory is
  55.             swapped. (in bytes) Use FNVirtualMemory_AdviseSwapSize to get
  56.             the VMM's advise of what SwapSize% should best be used under the
  57.             given circumstances. If SwapSize% is set to zero the value
  58.             returned by SWI VirtualMemory_AdviseSwapSize is automatically
  59.             used.
  60.  
  61. R1          is the amount of virtual memory in bytes. Use
  62.             FNVirtualMemory_AdviseMaximumVMSize() to get the VMM's advise of
  63.             what is possible under the given circumstances. If Size% is set
  64.             to zero then the value returned by
  65.             SWI VirtualMemory_AdviseMaximumVMSize is used
  66.  
  67.  
  68. R2          is a pointer to the path/filename where you want the
  69.             VirtualMemory to reside.
  70.  
  71. On Exit:
  72. ========
  73.  
  74. R0      A pointer to a description-block
  75.  
  76. Offset:         R0+0       Length of VirtualMemory that was created. (bytes)
  77.                 R0+4       Size of memory in which VM is being swapped.
  78.                            (bytes)
  79.                 R0+8       Pointer to the start of the swapmemory.
  80.                 R0+12      FileHandle. For VirtualMemoryManager use only! **
  81.                 R0+16      FilePointer. For VMM use only! ****
  82.                 R0+20      Filename. Null-terminated. For VMM use only! ****
  83.  
  84. R1,R2   Corrupted
  85. R3-R7   Preserved
  86.  
  87.  
  88. **** SWI VirtualMemory_Lose
  89.  
  90. On Entry:
  91. =========
  92.  
  93. R0              the pointer to the descriptionblock that was earlier
  94.                 returned by SWI VirtualMemory_Create 
  95.  
  96. On Exit:
  97. ========
  98.  
  99. R0      Corrupted
  100. R1-R7   Preserved
  101.  
  102. VirtualMemory discfile removed and RMA memory released. 
  103. NOTE: For some reason the released RMA memory does not always return to the
  104. free memory pool.
  105.  
  106.  
  107.  
  108. **** SWI VirtualMemory_Ensure
  109.  
  110. Everytime that you wish to use a block of VM of which you're not certain
  111. that it is currently in memory, you should call this SWI. The SWI makes sure
  112. that the currently loaded VM portion is saved and the required portion is
  113. loaded.
  114.  
  115. On Entry: 
  116. =========
  117.  
  118. R0              The pointer to the descriptionblock supplied to you earlier
  119.                 via SWI VirtualMemory_Create
  120.  
  121. R1              The offset (in bytes) into the VirtualMemory where you want
  122.                 to start using the memory.
  123.  
  124. R2              The minimum number of bytes that you want to access. This
  125.                 can never be more than the size of the swapmemory! If this
  126.                 is set to zero then the size of the swapmemory is used.
  127.  
  128. The VMM checks whether the required block is already completely loaded into
  129. the swapmemory. If it is, it just returns a pointer to the location in the
  130. swapmemory. If the required block is not (completely) resident in the
  131. swapmemory, the VMM will first save this swapmemory and then load the
  132. required block into the swapmemory.
  133.  
  134. On Exit:
  135. ========
  136.  
  137. R0      Preserved
  138. R1      Offset into the swapmemory where the requested block starts.
  139. R2-R7   Preserved       
  140. DescriptionBlock updated
  141.  
  142. Remember that only the specified minimum size (Size%) is ensured. If you
  143. want to access an offset beyond this block you must call this function
  144. again. NEVER EVER assume an offset of zero!!
  145.  
  146.  
  147.  
  148. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  149.  
  150. The SWI loads the requested part of the virtual-memory into the
  151. swap-memory and returns the offset into the VM-discfile. Normally this will
  152. be the same as R1. Except when the distance of R1 to the end of the file is
  153. less than the size of the swapmemory. In that case the SWI adjusts R1 so
  154. that the entire swapmemory is still used. The following graphs should
  155. clarify this...
  156.  
  157. Normal situation:                               
  158.  
  159. SWI VirtualMemory_Ensure,<Handle>,200,0
  160.  
  161. This loads the portion of the VM at address 200 into the swapmemory at
  162. offset 0 
  163. The SWI returns: 0
  164.  
  165. 0                               500
  166. +-------------------------------+  
  167. |       |       :       |       | VirtualMemory
  168. |       |       :       |       | 
  169. |       |       :       |       |
  170. +-------------------------------+
  171.         200     300     400
  172.         \                 /
  173.          \               /
  174.           +-------+-----+
  175.           |       :     | SwapMemory
  176.           |       :     |
  177.           +-------+-----+
  178.           0       100   200
  179.  
  180. Exceptional situation:                               
  181.  
  182. SWI VirtualMemory_Ensure,<Handle>,400,0
  183.  
  184. This loads the portion of the VM at address 300 into the swapmemory at 
  185. offset 0                  
  186. Because:
  187.  
  188. 1. 500-400=100
  189. 2. The SwapMemory has a size of 200
  190. 3. Therefore another 100 need to be loaded from offset (400-100=) 300.
  191.  
  192. So, in this case the SWI returns: 100 
  193.  
  194. 0                               500
  195. +-------------------------------+  
  196. |               :       |       | VirtualMemory
  197. |               :       |       | 
  198. |               :       |       |
  199. +-------------------------------+
  200.                 300     400     500
  201.                 /       /       /
  202.                /       /       /
  203.               +-------+-------+
  204.               |       :       | SwapMemory
  205.               |       :       |
  206.               +-------+-------+
  207.               0       100     200
  208.                       |
  209.                       +-> Requested