home *** CD-ROM | disk | FTP | other *** search
- Help on the Virtual Memory Manager Module
- ==========================================
-
- This module contains a number of SWI's that allow your programs to use more
- memory than is currently available. This is done by using Virtual Memory
- (VM). VM is a discfile. A small portion of your computer's memory (RMA) is
- used to load a part of this VM-discfile. Every time you wish to access
- another part of this VM, the appropriate section of the discfile is loaded.
- Thus, enabling you to use, say, 16Mb on a 1Mb machine. At this moment
- applications for RISCOS do not know about this VirtualMemoryManager (VMM).
- So, at this moment you can only include it into your own applications.
- Hopefully, in the (near) future other companies will incorporate this idea
- into their own applications. Enhancing your systems capacities beyond your
- wildest dreams...
-
- The program VVMModDemo demonstrates the use of the module. Use it by starting
- it from the *-prompt. If you want to see it working in a multi-tasking
- environment then you should open a Task window and run it from there. The
- reason why the demo itself isn't multi-tasking is, so the functioning of the
- program is not obscured by the parts of the program that supply the
- multi-tasking abilities.
-
-
- The following SWI's are supplied:
-
-
-
- **** SWI VirtualMemory_AdviseSwapSize
-
- On Entry:
- =========
-
- -
-
- On Exit:
- ========
-
- R0 Advised amount of bytes
- R1-R7 Preserved
-
- Returns the advised amount of bytes to pass to SWI VirtualMemory_Create as
- the swapmemory size. The algorithm used takes into account the
- system's total memory and the system's free memory (RMA's largest block and
- the free pool). From this the advised amount is calculated. Preferably you should not deviate from this.
-
-
- **** SWI VirtualMemory_Create
-
- This call initialises the amount of virtual memory that you need.
-
- On Entry:
- =========
-
- R0 is the amount of 'real' memory in which the virtual memory is
- swapped. (in bytes) Use FNVirtualMemory_AdviseSwapSize to get
- the VMM's advise of what SwapSize% should best be used under the
- given circumstances. If SwapSize% is set to zero the value
- returned by SWI VirtualMemory_AdviseSwapSize is automatically
- used.
-
- R1 is the amount of virtual memory in bytes. Use
- FNVirtualMemory_AdviseMaximumVMSize() to get the VMM's advise of
- what is possible under the given circumstances. If Size% is set
- to zero then the value returned by
- SWI VirtualMemory_AdviseMaximumVMSize is used
-
-
- R2 is a pointer to the path/filename where you want the
- VirtualMemory to reside.
-
- On Exit:
- ========
-
- R0 A pointer to a description-block
-
- Offset: R0+0 Length of VirtualMemory that was created. (bytes)
- R0+4 Size of memory in which VM is being swapped.
- (bytes)
- R0+8 Pointer to the start of the swapmemory.
- R0+12 FileHandle. For VirtualMemoryManager use only! **
- R0+16 FilePointer. For VMM use only! ****
- R0+20 Filename. Null-terminated. For VMM use only! ****
-
- R1,R2 Corrupted
- R3-R7 Preserved
-
-
- **** SWI VirtualMemory_Lose
-
- On Entry:
- =========
-
- R0 the pointer to the descriptionblock that was earlier
- returned by SWI VirtualMemory_Create
-
- On Exit:
- ========
-
- R0 Corrupted
- R1-R7 Preserved
-
- VirtualMemory discfile removed and RMA memory released.
- NOTE: For some reason the released RMA memory does not always return to the
- free memory pool.
-
-
-
- **** SWI VirtualMemory_Ensure
-
- Everytime that you wish to use a block of VM of which you're not certain
- that it is currently in memory, you should call this SWI. The SWI makes sure
- that the currently loaded VM portion is saved and the required portion is
- loaded.
-
- On Entry:
- =========
-
- R0 The pointer to the descriptionblock supplied to you earlier
- via SWI VirtualMemory_Create
-
- R1 The offset (in bytes) into the VirtualMemory where you want
- to start using the memory.
-
- R2 The minimum number of bytes that you want to access. This
- can never be more than the size of the swapmemory! If this
- is set to zero then the size of the swapmemory is used.
-
- The VMM checks whether the required block is already completely loaded into
- the swapmemory. If it is, it just returns a pointer to the location in the
- swapmemory. If the required block is not (completely) resident in the
- swapmemory, the VMM will first save this swapmemory and then load the
- required block into the swapmemory.
-
- On Exit:
- ========
-
- R0 Preserved
- R1 Offset into the swapmemory where the requested block starts.
- R2-R7 Preserved
- DescriptionBlock updated
-
- Remember that only the specified minimum size (Size%) is ensured. If you
- want to access an offset beyond this block you must call this function
- again. NEVER EVER assume an offset of zero!!
-
-
-
- @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
-
- The SWI loads the requested part of the virtual-memory into the
- swap-memory and returns the offset into the VM-discfile. Normally this will
- be the same as R1. Except when the distance of R1 to the end of the file is
- less than the size of the swapmemory. In that case the SWI adjusts R1 so
- that the entire swapmemory is still used. The following graphs should
- clarify this...
-
- Normal situation:
-
- SWI VirtualMemory_Ensure,<Handle>,200,0
-
- This loads the portion of the VM at address 200 into the swapmemory at
- offset 0
- The SWI returns: 0
-
- 0 500
- +-------------------------------+
- | | : | | VirtualMemory
- | | : | |
- | | : | |
- +-------------------------------+
- 200 300 400
- \ /
- \ /
- +-------+-----+
- | : | SwapMemory
- | : |
- +-------+-----+
- 0 100 200
-
- Exceptional situation:
-
- SWI VirtualMemory_Ensure,<Handle>,400,0
-
- This loads the portion of the VM at address 300 into the swapmemory at
- offset 0
- Because:
-
- 1. 500-400=100
- 2. The SwapMemory has a size of 200
- 3. Therefore another 100 need to be loaded from offset (400-100=) 300.
-
- So, in this case the SWI returns: 100
-
- 0 500
- +-------------------------------+
- | : | | VirtualMemory
- | : | |
- | : | |
- +-------------------------------+
- 300 400 500
- / / /
- / / /
- +-------+-------+
- | : | SwapMemory
- | : |
- +-------+-------+
- 0 100 200
- |
- +-> Requested