home *** CD-ROM | disk | FTP | other *** search
-
- Virtual Store Interrupts and Pageing
-
- A recent letter by Maurice Hendrix described how he would
- like Virtual memory management under Risc-OS and included
- an implementation. I had earlier thought that the job was
- too much bother and not useful enough but having looked
- at what he was doing have come to accept that he really
- does have a point.
-
- I have implemented a simple virtual store interrupt
- handler in a Basic program 'VSI_Sieve' accompanying this
- note. The sieve program is as in the program by Maurice
- Hendrix except that the pages are automatically paged in
- as necessary when they are referenced. Up to 8 Mbyte of
- virtual store starting at &800000 can be used if the disk
- space is available. The big restriction is that references
- to the virtual store area must not be passed to Risc-OS.
- the virtual store handling only works for programs in
- user mode - in particular *LOAD or *SAVE will not work.
-
- The program is single tasking and will not run in a Task
- window. However hooks are provided for running under the
- Wimp. One way of working might be to put all the Wimp
- related processing and data into the low addresses and all
- the computation and tables into the virtual store area.
-
- There is obviously endless scope for development and
- improvements. The most obvious to me are:
-
- 1. Have a virtual store module like in the implementation
- by Maurice Hendrix that would allocate space to tasks from
- the space of a 'Virtual Store Application' the size of which
- could be changed easily.
-
- 2. Implement a way of running C programs in the virtual
- store space and calling them from programs in lower space.
- All the Ansi C calls except fread, fwrite, setvbuf, and
- system look like they can be handed over direct to the current
- library.
-
- 3. Allow use in a task window by simply remapping a page
- if it is present but the mapping has changed unexpectedly.
- Implementing the handling in a module may mean the job can be
- done more elegantly.
-
- 4. There is room for efficiency improvements. The page
- replacement policy could certainly be improved. An option
- could be set to do a Wimp_Poll call when a VSI happens
- and do the transfers in the background.
-
- With these developments large C programs could be run
- quite easily in virtual store. The only space that would
- be locked in store would be the Wimp front ends. In fact I
- believe the main use could be to allow large programs to
- sleep in the background without consuming space when they
- are not actually processing.
-
- So how does virtual store work out in practice in VSI_Sieve?
- Sadly this program is not structured to use virtual store
- efficiently. The program does repeated linear passes through
- the data so every page keeps being loaded in in turn - there
- is no real working set at any stage. And there are a lot of
- passes when trying to find the millionth prime using a megabyte
- of virtual store. I estimate the program should take a couple
- of days to do the job but I haven't the patience. The program
- could be better structured to count all the primes in a block
- at a time - also this would be more sensible than trying to
- estimate in advance how many numbers to look at to get to
- the millionth prime.
-
- Run VSI_Sieve with a top limit of 1000000 and a current
- directory with a quarter megabyte free. This will make the disk
- chatter for a while and eventually report the number of primes
- below a million. Smaller values than about 800000 don't require
- pageing.
-
-