holtt@jacobs.CS.ORST.EDU (Tim Holt) (01/25/91)
I'm working on a memory-hungry package and need to maintain large/huge arrays on the order of 1 meg. I'd like to do this with extended mem and/or virtual mem, and am wondering if anyone has suggestions for a PD or commercial package for Turbo Pascal. My target machine is from 8086 on up, so I can't make any assumptions about the processor. Suggestions? Thanks! Tim Holt Oregon State University/Oceanography/Geophysics holtt@jacobs.cs.orst.edu
stoeen@solan.unit.no (Asbj|rn St|en) (01/27/91)
In article <1991Jan24.210122.5363@usenet@scion.CS.ORST.EDU>, holtt@jacobs.CS.ORST.EDU (Tim Holt) writes: |> I'm working on a memory-hungry package and need to maintain large/huge |> arrays on the order of 1 meg. I'd like to do this with extended mem |> and/or virtual mem, and am wondering if anyone has suggestions for a |> PD or commercial package for Turbo Pascal. My target machine is from |> 8086 on up, so I can't make any assumptions about the processor. |> Suggestions? Thanks! I think you should know that the 8086 does *not* support extended memory. To do this you must have at least an 80286. Also, you will have to run in protected mode to have hardware support for virtual memory (not supported by the 8086). But, of course, there might be some packages that implement such large structures using a hard disk, but then again, you can't use ordinary array operators (square brackets), you will be limited to some functions. Thus, using virtual memory is possible, but extended is not. However, exPAnded memory can be used with any processor (this is the most common way to use memory). If you don't get hold of a PD package, you can use an ordinary file with your array type. People who have enough extended memory (or expanded), can then put the file on a RAM disk, increasing speed. If you have to use a hard disk, this method could of course be hopelessly slow. If you are an experienced programmer, you could try to implement virtual memory yourself. I will sketch the structure here: - Allocate a fixed number of page frames in memory. You will have to keep some status for each page, e.g. 'written_to' and offset into virtual memory (and a status bit for 'used'). - Create a replacement queue, where the first page in the queue is the first page to be replaced (or put into use) when you have to read another page into memory. - When your virtual memory manager receives a command for read or write to memory, it tests whether the page referred to is in memory. If it is, it performs the operation and places the referred page at the end of the queue. If the page doesn't exist in memory, throw out the first page in the queue. If it is marked 'written_to', you will have to write it onto disk first. After the new page is read into memory, you can retry the whole operation. - When you create an array (for simplicity, of fixed size), you will have to create an object which holds the offset of the array into your virtual memory. You will also have to know the size of each element. The memory manager gets information about the next free location in virtual memory. - To find out the address of a read or write operation, multiply the array index (assumed starting at 0) by the size of each element, then add the offset of the first element. Then scan through the page status to find whether this address is within some of the used pages. The main problem connected to this is that you will have to divide the read/write operation into several parts if the object resides in several contiguous pages at the same time. - Warning: When copying elements from one location in virtual memory to another, make sure that the copy operation is done through a temporary object (or else the destination page may be throwed out, and a hard-to-find bug may occur.) - You can let your object inherit the properties of the base virtual class to improve readability (such as not needing to pass the size of the object as a parameter every time). I know this sounds a bit complicated. However, there are no algorithmic problems with this, and really few data structures to keep hold of, so the programming is actually quite straightforward. You could let me know if you have any questions to any of the above. One final note, if you had used Zortech C++ Developers Edition, you would have had these facilities. The Zortech C++ Tools support both dynamic virtual arrays and use of expanded memory. ------------------------------------------------- | _ | |Asbjoern Stoeen / \ /___ | |Studpost 188 /___\ // | |7034 Trondheim-NTH / \ / \__ | |Norway / \ | | / ___/ | -------------------------------------------------
ts@uwasa.fi (Timo Salmi) (01/27/91)
>In article <1991Jan24.210122.5363@usenet@scion.CS.ORST.EDU>, holtt@jacobs.CS.ORST.EDU (Tim Holt) writes: >|> I'm working on a memory-hungry package and need to maintain large/huge >|> arrays on the order of 1 meg. I'd like to do this with extended mem >|> and/or virtual mem, and am wondering if anyone has suggestions for a >|> PD or commercial package for Turbo Pascal. My target machine is from >|> 8086 on up, so I can't make any assumptions about the processor. >|> Suggestions? Thanks! : You'll find some information on this is /pc/ts/tsfaq17.arc. The wares are available by anonymous ftp from garbo.uwasa.fi, Vaasa, Finland, 128.214.12.37, or by using our mail server (use the latter if, and only if you don't have anonymous ftp). If you are not familiar with anonymous ftp or mail servers, I am prepared to send prerecorded instructions on request. (If you don't get the instructions from me within a few days, it will mean that your email address cannot be reached by a simple email reply, and you wouldn't be able to utilize the mail server anyway.) ................................................................... Prof. Timo Salmi Moderating at garbo.uwasa.fi anonymous ftp archives 128.214.12.37 School of Business Studies, University of Vaasa, SF-65101, Finland Internet: ts@chyde.uwasa.fi Funet: gado::salmi Bitnet: salmi@finfun
dosborn@hydra.unm.edu (David Osborn) (01/27/91)
In article <1991Jan26.195955.12946@ugle.unit.no> stoeen@solan.unit.no (Asbj|rn St|en) writes: >In article <1991Jan24.210122.5363@usenet@scion.CS.ORST.EDU>, holtt@jacobs.CS.ORST.EDU (Tim Holt) writes: >|> I'm working on a memory-hungry package and need to maintain large/huge >|> arrays on the order of 1 meg. I'd like to do this with extended mem >|> and/or virtual mem, and am wondering if anyone has suggestions for a >|> PD or commercial package for Turbo Pascal. My target machine is from >|> 8086 on up, so I can't make any assumptions about the processor. >|> Suggestions? Thanks! > [...Asbjoern's comments deleted. Sorry, I lost the original post.] One commercial package which has been quite useful for me is TurboPower Softwares' Object Professional (for TP5.5 & 6.0 OOPs) and their non-object version Turbo Professional (for TP5.0, 5.5, 6.0, not sure on 4.0). Both versions have units (with source) to create arrays either on disk or in EMS. The package also contains a wealth of other routines which have saved me considerable time in writing ad hoc programs. Dave. ------------------------------------------------------------------------------ The real danger is not that computers David W. Osborn will think like men, but that men will dosborn@hydra.unm.edu begin to think like computers. University of New Mexico - Sydney J. Harris -----------------------------------------------------------------------------