Virtual Memory.
More...
|
T_word32 | IVMAppendEntry (T_vmFile file) |
|
T_void | IVMCreate (T_vmFileInfo *p_fileInfo) |
|
T_vmBlock | IVMCreateBlockAtEnd (T_vmFile file, T_word32 size) |
|
T_vmBlock | IVMFindFreeBlockOfSize (T_vmFile file, T_word32 size) |
|
T_vmBlock | IVMFindLowestBlock (T_vmFile file, T_word32 place) |
|
T_void | IVMFree (T_vmFile file, T_vmBlock block) |
|
T_void | IVMRelease (T_vmFile file, T_vmBlock block) |
|
T_void | IVMSaveIfDirty (T_vmFileInfo *p_fileInfo, T_vmEntry *p_entry) |
|
T_void | IVMSaveIndex (T_vmFileInfo *p_fileInfo) |
|
T_void | IVMShiftBlockDown (T_vmFile file, T_vmBlock block, T_word32 *place) |
|
T_void | IVMTruncate (T_vmFile file, T_word32 place) |
|
T_void | IVMUpdate (T_vmFileInfo *p_fileInfo) |
|
T_vmBlock | VMAlloc (T_vmFile file, T_word32 size) |
|
T_void | VMCleanUp (T_byte8 *p_filename) |
|
T_void | VMClose (T_vmFile file) |
|
T_void | VMDecRefCount (T_vmFile file, T_vmBlock block) |
|
T_void | VMDirty (T_vmFile file, T_vmBlock block) |
|
T_word16 | VMGetRefCount (T_vmFile file, T_vmBlock block) |
|
T_void | VMIncRefCount (T_vmFile file, T_vmBlock block) |
|
void * | VMLock (T_vmFile file, T_vmBlock block) |
|
T_vmFile | VMOpen (T_byte8 *p_filename) |
|
T_void | VMUnlock (void *block) |
|
Virtual Memory.
Virtual Memory System – NOT USED!
- See Also
- http://www.amuletsandarmor.com/AALicense.txt
#define VM_ENTRY_GROW_SIZE 2000 |
#define VM_FLAG_DIRTY 0x40 |
#define VM_FLAG_IN_MEMORY 0x80 |
#define VM_SEMAPHORE_READ 0x20 |
#define VM_SEMAPHORE_WRITE 0x10 |
#define VM_SHIFT_BLOCK_SIZE 4000 |
IVMAppendEntry adds another entry at the bottom of the index.
- Parameters
-
file | – File to append an entry. |
IVMCreate opens up a new vm file and vm records file. Any previous data is lost.
- Parameters
-
p_fileInfo | – Pointer to file info structure to create. |
IVMCreateBlockAtEnd assumes that the best place for a new block is at the end of the records file (and at the end of the index). A new block is created there.
- Parameters
-
file | – File to append block to |
size | – Size of block |
IVMFindFreeBlockOfSize searches for the first block that meets the given size requirement. In addition, it splits the blocks accordingly.
NOTE: Based on the way this routine works, it is fast, but causes alot of fragmentation.
- Parameters
-
file | – File to search for block within |
size | – Size to find |
IVMFindLowestBlock searches the index to find the lowest block that is above the given file offset. If none is found, a zero is returned.
- Parameters
-
file | – File to release block within |
place | – Place in VM |
IVMFree takes a originally reference allocated block and frees it and puts it on the linked list of free blocks.
NOTE: Obviously you should not call this on an already freed block.
- Parameters
-
file | – File to free block within |
block | – Block that is being freed |
IVMRelease makes a block that was in memory be released to disk (and saves if necessary).
NOTE: Obviously you should not call this on an already freed block.
- Parameters
-
file | – File to release block within |
block | – Block that is being released |
IVMSaveIfDirty checks the given block if is dirty, and if so, saves it to disk. Otherwise, nothing happens.
- Parameters
-
p_fileInfo | – Pointer to the file information struct |
p_entry | – Pointer to entry to check to save |
IVMSaveIndex saves the index file.
- Parameters
-
p_fileInfo | – Pointer to the file information struct |
IVMShiftBlockDown moves a vm block within the records file to the given place. The byte after the block is also returned.
- Parameters
-
file | – File to shift block within |
block | – Block to shift |
place | – Place to shift down to (and variable to record end of block). |
IVMTruncate clips the end of the vm file so that the file takes up less disk space.
- Parameters
-
file | – File to truncate |
place | – where to truncate the file |
IVMUpdate saves all dirty records, mark them as clean, and then saves the whole index.
- Parameters
-
p_fileInfo | – Pointer to file info structure to update. |
VMAlloc does all the work of finding a block of the given size in the current virtual memory file. If no space can be found, a VM_BLOCK_BAD is returned.
- Parameters
-
file | – File to allocate vm block within |
size | – Size to make the vm block |
- Returns
- block handle to block, or VM_BLOCK_BAD
From time to time, files will become 'pitted' with free blocks that nothing will use. When this happens, all the free spots need to be compressed and expulged. All free spots are removed and everything is relocated correctly. Major files should have this routine called on them at least once a day. Note that this routine should only be called on FULLY CLOSED vm files. If you don't the file will be destroyed since two versions will exist (one in memory, one on disk).
NOTE: The VM file that is being cleaned-up should NOT be opened at this time. No checks are made to confirm this.
- Parameters
-
p_filename | – Name of file to clean-up |
VMClose closes out all of the records opened (but waiting to be written). All corresponding junk that is not needed is cleared from memory.
- Parameters
-
file | – File that is to be closed. |
VMDecRefCount decrements the count of references to this block. This number is very important since it tells whether or not the block is free. Accurate reference counts is a must. Note that newly VMAlloc'd blocks start with a reference count of 1. A reference count of 0 is a free block.
NOTE: VMDecRefCount may destroy all data related to the block if the reference count goes to zero. Make VMDecRefCount the last action performed on any block.
- Parameters
-
file | – File containing vm block to decrement |
block | – Block to decrement in vm file. |
VMDirty marks a block dirty so the block is saved to disk. Otherwise, the block is never saved and any changes are lost.
- Parameters
-
file | – File containing newly dirty block |
block | – Block in file to mark dirty |
VMGetRefCount returns the number of references to this block.
- Parameters
-
file | – File containing vm block to decrement |
block | – Block to decrement in vm file. |
VMIncRefCount increments the count of references to this block. This number is very important since it tells whether or not the block is free. Accurate reference counts is a must. Note that newly VMAlloc'd blocks start with a reference count of 1.
- Parameters
-
file | – File containing vm block to increment |
block | – Block to increment in vm file. |
VMLock is used to retrieve a block from the vm file. In addition, semaphoring is done to check for read/write access priviledges. A block can be locked with a semaphore on reading or writing. If locked for writing semaphore, no other locking actions for write access are allowed. If the lock requests read priviledge, but the block is locked with read semaphored, then the lock is stopped. In addition, a flag is added to allow for thread blocking. If TRUE, the calling will wait until the block is free. If FALSE, the calling process will not wait and will not return with a block pointer.
NOTE: In this current version, the routine does not make memory write protected even though the semaphores may request read only. It is up to the programmer to make sure read and writes are appropriate to the semaphore accesses.
- Parameters
-
file | – File containing vm block to decrement |
block | – Block to decrement in vm file. |
- Returns
- Pointer to data block, or NULL
VMOpen opens a file for VM file access. If the file does not exist, it is created. Minimal setup is used when first created. Pass to this routine the filename WITHOUT an extension. A .idx postfix is added for the index and A .rec postfix is added for the records file.
- Parameters
-
p_filename | – File to open for VM access. |
- Returns
- File that was opened.
T_void VMUnlock |
( |
void * |
block) | |
|
VMUnlock releases the vm block from memory. If multiple locks have been executed, an equal number of unlocks must be performed to remove the block from memory.
- Parameters
-
block | – Pointer to block previously locked |