Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!apple!agate!volcano.Berkeley.EDU!kawakami From: kawakami@volcano.Berkeley.EDU (John Kawakami) Newsgroups: comp.sys.atari.st.tech Subject: Re: 1.44M 3.5 disks // floppies as swap space Message-ID: <1990Sep21.033418.14446@agate.berkeley.edu> Date: 21 Sep 90 03:34:18 GMT References: <1990Jul31.165603.20869@msuinfo.cl.msu.edu> <1407@wet.UUCP> <1990Sep10.105324.26957@agate.berkeley.edu> <10562@life.ai.mit.edu> Sender: usenet@agate.berkeley.edu (USENET Administrator) Reply-To: kawakami@volcano.Berkeley.EDU (John Kawakami) Organization: ucb Lines: 57 In article <10562@life.ai.mit.edu> entropy@rice-chex.ai.mit.edu (enthalpy) writes: >No! You would still have to handle the case where someone actually >tries to _access_ data that has been paged out (you mean you have to >be able to read it back??). This entails first of all being able to >recognize an interrupt caused by accessing memory that was paged out Not with the scheme I described. First, you need a table of all the memory pages. For simplicity's sake, make it an array: struct memptr{ word *memaddr; word statusbits; } /*sorry I don't know*/ /*how to use bitfields*/ struct memptr pagetable[4096]; /* arbitrary */ Then you need to write mallocs which don't return pointers to memory fragments but indices into the pagetable. (actually, you need to write something at a lower level than malloc) int malloc(int size) { /*blah blah*/ /* figure out which block to allocate*/ /*see where in memory or disk that block really is and*/ /*set some status bits*/ return pagetableindex<>offsetbits*/ /*check the status bits to see where the block is (in memory or on disk)*/ /*if it is on disk swap something out and swap that page in*/ return actualladdress+offest; } Then you publish docs telling people to use the deref() func or they will have funny things happen to their programs. I've made this seem easier than it looks. There are extensions you can do as well. Maybe a new func which will set a protect bit so a page will not be swapped out, a func to unset it, and then you can use normal dereferencing instead of handles in between the set and unset of the protect bit. This is not a nice way to have things done, but it is not uncommon. MacOS and Windows 2 do this, as someone pointed out. Some languages have this built in so program fragments can be swapped in and out: instead of a pagetable there is a functiontable. John Kawakami kawakami@ocf.berkeley.edu ucbvax!ocf.berkeley.edu!kawakami Amateur crank! My Atari Macks!