home *** CD-ROM | disk | FTP | other *** search
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- VIRTUAL MEMORY MANAGEMENT SYSTEM 1.0
-
- For Turbo Pascal Version 5.0
-
-
-
-
-
-
-
-
-
-
-
-
- Copyright 1990, 1991 By
-
- Software Technology International
-
- All Rights Reserved
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 1
-
- NOTICE
- ------
-
-
-
- All parts of this manual and the accompanying soft-
- ware are copyrighted material. You, as a registered
- user, are granted permission to make as many copies of
- the software, or manual, as you wish, as long as they
- are for your personal use. You may not copy this soft-
- ware, or manual, in any form whatsoever for usage
- outside of your personal use. This includes, but is not
- limited to, duplication of the disk, the files on the
- disk or the manual, by manual or electronic means.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 2
-
- TABLE OF CONTENTS
- -----------------
-
-
- Subject Page
- -----------------------------------------------------
-
- GENERAL DESCRIPTION ...................... 4
- Introduction ........................... 4
- The software ........................... 4
-
- THE SOFTWARE IN DETAIL ................... 5
- Function Return Codes .................. 5
- Functions and Procedures ............... 6
- Usage Pointers ......................... 9
-
- INDEX .................................... 10
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 3
-
- GENERAL DESCRIPTION
- -------------------
-
- Introduction
- ------------
-
- Welcome to Version 1.0 of Software Technology Inter-
- nationals' Virtual Memory Management System. This group
- of functions will enable your Turbo Pascal Version 5.0
- access to up to 40 megabytes of data. The functions
- were written to be flexible, as fast as possible, and
- as easy to use as possible. We hope they live up to
- your expectations. Please feel free to write to us
- anytime with bug reports or suggestions for future
- versions. If you are a registered user, this will
- entitle you to a free upgrade.
- Remember that this software is copyrighted, so
- please don't copy and distribute it, this is a federal
- offense.
-
- The Software
- ------------
-
- This is a group of 10 functions and procedures which
- will give your programs access to up to 40 megabytes of
- data. To be exact, the system supports up to 10 swap
- files with up to 65535 pages of up to 65535 bytes each.
- If you add this up, you get a total of 42,948,362,250
- bytes you may access. Each of those swap files may have
- up to 4096 pages resident in conventional memory, de-
- pending on the page size.
-
- There is no restriction on the type of data these
- functions may handle, so any valid Turbo Pascal type
- may be stored and accessed through these functions.
-
- The system takes advantage of the fact that most
- programs spend a lot of time in each area of memory,
- and generally don't access all elements in order. This
- is called locality, and is well known in Operating
- System circles. The program uses the LRU (Least Recent-
- ly Used) algorithm to try to keep cache misses to a
- minimum.
-
- Access to a page that is resident on disk, is of
- course a lot slower than directly accessing memory. You
- will find however, that with a good hard disk, or a RAM
- disk, the difference will not be so great. However,
- with floppy disks, things will be a lot slower.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 4
-
- THE SOFTWARE IN DETAIL
- ----------------------
-
-
- The Function and Procedure Return Codes
- ----------------------------------------
-
- All of the functions use the following error codes
- for return values.
-
- ALL_OK = 0;
-
- This is used to signify that the function managed to
- complete with no errors.
-
- BAD_VM_ID = -1;
-
- This is used to signify that the ID variable that
- you passed to the function is invalid. This is due to
- either the number being to large or too small, the swap
- file being already used, or the swap file not having
- being initialised (opened).
-
- PAGE_SIZE_TOO_BIG = -2;
-
- This is used to show that the page size is over
- 65535 bytes. You should reduce the size of the data
- structure you are trying to allocate.
-
- PAGE_SIZE_TOO_SMALL = -3;
-
- This is used to show that the page size is too
- small. In fact, this is never returned because all
- pages less that 128 bytes are rounded up.
-
- CACHE_SIZE_TOO_BIG = -4;
-
- This is used to show that the cache size is greater
- than 4096 pages. You should reduce the size.
-
- CACHE_SIZE_TOO_SMALL = -5;
-
- This is used to indicate that the cache size is too
- small, or less than one page. You should increase the
- size to 1 or more.
-
- FILE_CREATE_ERROR = -6;
-
- This is used to indicate that the system could not
- create, or open the file specified. Check the file
- names, or space on the disk.
-
-
-
-
-
-
-
-
-
-
-
-
-
- 5
-
- OUT_OF_MEMORY = -7;
-
- This is used to show that the system has run out of
- conventional memory. This is due to the caches being to
- large, or the page size being too large. Check all of
- these parameters.
-
- BAD_PAGE_NUMBER = -8;
-
- This is used to indicate that the page number handed
- to the system is either too big, or too small. That is,
- this page has not been allocated.
-
-
- The Functions And Procedures
- ----------------------------
-
-
- function STI_VM_Open(ID : byte;
- Swap : string;
- Page_Size,
- Cache : word) : shortint;
-
- This is the function you can use to create a new
- swap file. The ID variable is the number of the swap
- file. The SWAP variable is the path and file name for
- the swap file. The PAGE_SIZE is how large the pages
- are, and the CACHE is how many pages to cache in memo-
- ry. The return codes are exactly the same as those
- above. The only important point here is that the page
- size is always rounded up to a multiple of 128, so it
- is better to try to make your data structures a multi-
- ple of 128 bytes, otherwise you will waste memory.
-
-
- function STI_VM_ReOpen(ID : byte;
- Swap : string) : shortint;
-
- This function is used to open a previously created
- swap file. The ID and SWAP variables are exactly the
- same as for the function above. The only difference is
- that all the other parameters are read in from the swap
- file. This gives you a very powerful ability to swap
- data between applications without having to know all
- the details of the data structure. With this, you
- should be able to transfer data or RUN TIME LIBRARIES
- between programs. You can do this by copying a function
- or program without a header to the swap file, and then
- calling the first byte of the page.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 6
-
- function STI_VM_Flush_Cache(ID : Byte) : shortint;
-
- This function is used to flush the cache associated
- with the ID variable. The ID variable must be a valid
- (opened) ID or the function will return an error. The
- error codes are as above.
-
- function STI_VM_Allocate(ID : byte;
- Var Point) : longint;
-
- This is the function you should use to allocate a
- virtual page. The ID variable must be a valid (opened)
- ID. The POINT variable should be a pointer to ANY valid
- Turbo Pascal type. The pointer will be set to point to
- an area of memory that can be used in the regular way.
- The return codes of this function are the same as
- above, or it will return the positive PAGE NUMBER.
-
- function STI_VM_Demand(ID : byte;
- Var Point;
- PageNo : word) : shortint;
-
- This function is used to demand a page, or to make
- sure a page is in memory. It is wise to do this before
- every memory access, unless the cache size, and the
- number of pages is the same(a rare case). The ID is a
- valid (opened) ID variable, the POINT is a pointer to
- ANY valid Turbo Pascal type, and the PAGENO is the
- previously allocated page number. Functions returns are
- as above.
-
-
- function STI_VM_Rollback(ID : byte;
- Var Point;
- PageNo : word) : shortint;
-
- This function is used to erase changes you have made
- to a cached page. It will read in the page from disk
- and reassign the pointer, if necessary. This will only
- work if the page hasn't been written out after the
- changes, and the page was written out recently before
- the changes. The ID is any valid ID variable, the POINT
- is a pointer to any valid Turbo Pascal type, and the
- PAGENo is any valid page number. Return codes are as
- above.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 7
-
- function STI_VM_Close(ID : byte;
- EraseFile : boolean) : shortint;
-
- This function is used to close a swap file, and
- erase the contents of memory. First it flushes the
- cache, and then it frees up the memory. The ID is any
- valid ID variable, and the ERASEFILE is a flag telling
- the system whether it should erase the file or not.
- Return codes are as above.
-
- function STI_VM_Hit_Rate : real;
-
- This function returns the percentage ratio of cache
- hits to misses. You must call STI_VM_Log_Cache before
- you use this, otherwise the results will be false. This
- is useful for tuning thee system.
-
- procedure STI_VM_Init;
-
- This procedure initialises the system. It is a good
- idea to always call this, but is not strictly neces-
- sary.
-
- procedure STI_VM_Log_Cache(B : boolean);
-
- This procedure sets an internal flag, telling the
- system to log the performance of the caches. note that
- this is the performance of ALL the caches, not just
- one. So if you are fine tuning a system, it is a good
- idea to do so ONE SWAP FILE AT A TIME.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 8
-
- USAGE POINTERS
- --------------
-
- If you look at the demostration program, you can see
- an example of how each function is used. In general
- though, you don't have to follow this example. In real
- use, basically you have to do the following.
-
- 1) Initialise the system using STI_VM_Init,
- but this is not vitally important.
- 2) Open a swap file using STI_VM_Open. Using sizeof()
- for specifiying page size is recommended.
- 3) Allocate the pages you need using STI_VM_Allocate.
- 4) Access and modify the data. To do this it is
- recommended that you use STI_VM_Demand before
- accessing every data item.
- 5) Close the swap file using STI_VM_Close.
-
- You should be aware that having a big cache will
- generally result in better performance, but not always.
- The most important thing here is how your program
- accesses the data. If it accesses the data sequential-
- ly, forward and then backward, a large cache will be
- very effective, otherwise, try to minimize the size of
- the cache. If you use the STI_VM_Log, and
- STI_VM_Hit_Rate functions, you will be able to see the
- point at which performace is best.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 9
-
- INDEX
- -----
-
- Topic Page Number
- -------------------------------------------------------
-
- Algorithm ................................ 4
- ALL_OK ................................... 5
-
- BAD_PAGE_NUMBER .......................... 6
- BAD_VM_ID ................................ 5
-
- Cache Performance ........................ 8
- Cache Size ............................... 6
- CACHE_SIZE_TOO_BIG ....................... 5
- CACHE_SIZE_TOO_SMALL ..................... 5
- Contents ................................. 3
- Copying .................................. 2
- Copyright ................................ 2
-
- Data ..................................... 7
- Data Changes ............................. 7
- Data Types ............................... 4, 7
- Description .............................. 4
- Descriptions ............................. 6
-
- EraseFile ................................ 8
- Exchanging Data .......................... 6
-
- FILE_CREATE_ERROR ........................ 5
- Functions ................................ 6
-
- ID ....................................... 6
- Initialisation ........................... 8
-
- Number of Pages .......................... 4
-
- OUT_OF_MEMORY ............................ 6
-
- Page Size ................................ 6
- Pages .................................... 7
- Pages Sizes .............................. 4
- PAGE_SIZE_TOO_BIG ........................ 5
- PAGE_SIZE_TOO_SMALL ...................... 5
- Pointers ................................. 7
- Procedures ............................... 6
-
- Return Codes ............................. 5
-
- Software ................................. 4
- STI_VM_Allocate .......................... 7
- STI_VM_Close ............................. 8
- STI_VM_Demand ............................ 7
- STI_VM_Flush_Cache ....................... 7
- STI_VM_Hit_Rate .......................... 8
-
-
-
-
-
-
-
-
-
- 10
-
- STI_VM_Init .............................. 8
- STI_VM_Log_Cache ......................... 8
- STI_VM_Open .............................. 6
- STI_VM_ReOpen ............................ 6
- STI_VM_Rollback .......................... 7
- Swap File Size ........................... 4
- Swap Files ............................... 8
-
- Usage .................................... 9
- Usage Steps .............................. 9
- Users .................................... 2, 4
-
- Virtual Memory ........................... 4
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 11
-
-