home *** CD-ROM | disk | FTP | other *** search
/ APDL Public Domain 1 / APDL_PD1A.iso / program / virtual / VSI_Basic / Letter next >
Encoding:
Text File  |  1992-09-20  |  3.4 KB  |  78 lines

  1.  
  2. Virtual Store Interrupts and Pageing
  3.  
  4. A recent letter by Maurice Hendrix described how he would 
  5. like Virtual memory management under Risc-OS and included 
  6. an implementation. I had earlier thought that the job was 
  7. too much bother and not useful enough but having looked 
  8. at what he was doing have come to accept that he really 
  9. does have a point.
  10.  
  11. I have implemented a simple virtual store interrupt 
  12. handler in a Basic program 'VSI_Sieve' accompanying this 
  13. note. The sieve program is as in the program by Maurice 
  14. Hendrix except that the pages are automatically paged in 
  15. as necessary when they are referenced. Up to 8 Mbyte of 
  16. virtual store starting at &800000 can be used if the disk 
  17. space is available. The big restriction is that references 
  18. to the virtual store area must not be passed to Risc-OS. 
  19. the virtual store handling only works for programs in 
  20. user mode - in particular *LOAD or *SAVE will not work.
  21.  
  22. The program is single tasking and will not run in a Task 
  23. window. However hooks are provided for running under the 
  24. Wimp. One way of working might be to put all the Wimp 
  25. related processing and data into the low addresses and all 
  26. the computation and tables into the virtual store area.
  27.  
  28. There is obviously endless scope for development and 
  29. improvements. The most obvious to me are:
  30.  
  31. 1. Have a virtual store module like in the implementation 
  32. by Maurice Hendrix that would allocate space to tasks from 
  33. the space of a 'Virtual Store Application' the size of which 
  34. could be changed easily.
  35.  
  36. 2. Implement a way of running C programs in the virtual 
  37. store space and calling them from programs in lower space.
  38. All the Ansi C calls except fread, fwrite, setvbuf, and 
  39. system look like they can be handed over direct to the current 
  40. library.
  41.  
  42. 3. Allow use in a task window by simply remapping a page 
  43. if it is present but the mapping has changed unexpectedly. 
  44. Implementing the handling in a module may mean the job can be 
  45. done more elegantly.
  46.  
  47. 4. There is room for efficiency improvements. The page 
  48. replacement policy could certainly be improved. An option 
  49. could be set to do a Wimp_Poll call when a VSI happens 
  50. and do the transfers in the background.
  51.  
  52. With these developments large C programs could be run 
  53. quite easily in virtual store. The only space that would 
  54. be locked in store would be the Wimp front ends. In fact I 
  55. believe the main use could be to allow large programs to 
  56. sleep in the background without consuming space when they 
  57. are not actually processing.
  58.  
  59. So how does virtual store work out in practice in VSI_Sieve? 
  60. Sadly this program is not structured to use virtual store 
  61. efficiently. The program does repeated linear passes through 
  62. the data so every page keeps being loaded in in turn - there 
  63. is no real working set at any stage. And there are a lot of 
  64. passes when trying to find the millionth prime using a megabyte 
  65. of virtual store. I estimate the program should take a couple 
  66. of days to do the job but I haven't the patience. The program 
  67. could be better structured to count all the primes in a block 
  68. at a time - also this would be more sensible than trying to 
  69. estimate in advance how many numbers to look at to get to 
  70. the millionth prime.
  71.  
  72. Run VSI_Sieve with a top limit of 1000000 and a current 
  73. directory with a quarter megabyte free. This will make the disk 
  74. chatter for a while and eventually report the number of primes 
  75. below a million. Smaller values than about 800000 don't require
  76. pageing. 
  77.  
  78.