Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!rutgers!sri-unix!husc6!bu-cs!bucsb.bu.edu!madd From: madd@bucsb.bu.edu.UUCP Newsgroups: comp.sys.ibm.pc Subject: Re: disk paging on IBM PC's Message-ID: <888@bucsb.bu.edu.UUCP> Date: Mon, 30-Mar-87 20:56:15 EST Article-I.D.: bucsb.888 Posted: Mon Mar 30 20:56:15 1987 Date-Received: Wed, 1-Apr-87 05:28:30 EST References: <475@batcomputer.tn.cornell.edu> Reply-To: madd@bucsb.bu.edu.UUCP (Jim "Jack" Frost) Organization: ODO (Organization for the Disorganization of Organization) Lines: 57 Keywords: editors, disk paging In article <475@batcomputer.tn.cornell.edu> rjj@batcomputer.tn.cornell.edu (rjj) writes: > >I am looking for an algorithm (written in 'C') that >would do demand disk paging from within a editor. >A language processor we are working on only has enough >buffer space available to keep 400 lines of text in >memory. What is needed is a small routine that will >update the total document on disk, page out the last >least used pages from memory and then read in more of >the text from the disk ( the reason for all this is that >the system will be run in language labs that have minimum >configuration IBM PC's). As far as I can tell, only >a couple of popular word processors can do this so it >might be trickier that it seems. If anybody can point >me down a golden-paved path I would be very grateful. > Rich Jaenson This is definitely trickier than it seems. I am currently working on an editor that is capable of this, and would like to give you some of my ideas so that you can have a base to build on. I'm sorry that I cannot give you prewritten routines -- I don't have them available. The simplest method of handling paged memory is to treat all of memory as paged (whether on or off disk) and only access it through certain routines, which take paging into consideration. My wordprocessor used 1K "pages" that were stored in linked lists. If you came to a section in the list that had a flag set to indicate that it was paged, you swap out one page (take your pick -- use any algorithm you want to figure out which page to swap) and reload the other page. Reset its pointers to fit it in the correct place in the list. The list must be made up of three elements, besides those used by your program. You must have a pointer to each page (via your language's structure pointer convention; C would be something like PAGE *page) and a boolean value to indicate if the page has been swapped. You must indicate where on disk the page has been swapped to, as well, and I recommend you overlap the memory pointer with the disk pointer. I personally used an integer value to determine which record number a particular page was in. It is an algorithm problem as to how you determine where on disk to put your record -- I just scanned the list and kept track of the lowest open page in the file of pages, as well as remembering the highest page yet written. There are other advantages to treating all of memory as "paged". For instance, it is simple to treat a couple of pages as the entire file, thus saving you time when you reorganize. You only have to move a few K of bytes instead of a few hundred. I hope this has been helpful. If you have more questions, write and I'll clarify things. Be sure to include several GOOD return paths (preferable ARPANET). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Jim Frost * The Madd Hacker | UUCP: ..!harvard!bu-cs!bucsb!madd H H | ARPA: madd@bucsb.bu.edu H-C-C-OH <- heehee +---------+---------------------------------- H H | "We are strangers in a world we never made"