home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 5 / DATAFILE_PDCD5.iso / utilities / t / tornado / Guide / 2 < prev    next >
Encoding:
Text File  |  1995-09-23  |  5.4 KB  |  91 lines

  1. Memory management
  2. -=-=-=-=-=-=-=-=-
  3.  
  4. Tornado manages its memory, and the memory of the apps under its control much
  5. differently from convention. The application image is stored in its task
  6. slot, allocated from the tornado memory pool, along with any internal data.
  7. Thankfully, unlike RISC-OS's 16Mb wimpslot limit, tornado applications enjoy
  8. a 4Gb maximum slot size. This part of the memory management is handled by the
  9. tornado shell.
  10.    All files loaded into tornado apps are stored in a heap located in the
  11. tornado multitasker's memory space (on MEMC1-1a machines the memory space is
  12. a standard wimpslot [1]; on later hardware it moves into a dynamic area).
  13. This heap's blocks are relocatable, and the heap is garbaged regularly. Any
  14. free space is returned immediately to the wimp's free pool. This part is
  15. handled by the tornado kernel.
  16.  
  17. [1] Note that on current implementations of tornado, the public area space
  18. (tornado system heap) resides in RMA, due to it being a lot easier to debug
  19. things when your heap doesn't keep getting corrupted. It is envisaged that in
  20. the future, files loaded into tornado will be kept in the main memory pool,
  21. and virtual memory applied there. However, as far as the application will be
  22. concerned the files will still be stored in the tornado system heap.
  23.  
  24.  
  25. The reason why files are kept in tornado's memory space is because:
  26.  (a): On every architecture, this method allows a slot up to machine RAM
  27. size. Obviously, this allows files of almost infinite length to be loaded
  28. when possible.
  29.  (b): Virtual memory techniques can be applied to data, whereby blocks (being
  30. relocatable) can be dumped to disc and copied back in when needed (i)
  31.  (c): The files are at the full reach of Tornado (it owning the memory), and
  32. so can be accessed without the owning task's permission. Obviously tornado
  33. apps must keep a copy of the file in a saveable format at all times - if this
  34. is not possible, the task must provide a routine to generate a saveable file
  35. [1]. Of course, _no_ task actually owns any files loaded into torando apps -
  36. except Tornado itself.
  37.    Advantages of this system of centralising files:
  38.         - Saves and insertion are/can be automated
  39.         - OLE and hotlinking can also be automated
  40.         - Convertors can be used to translate between formats. For example,
  41. if the user drags a GIF file to a Tornado app that can only accept Sprites,
  42. it gets converted first and dumped into tfs: to be loaded in. Being saved
  43. back, it get converted back. This is done by a specialised range of subtasks
  44. (see the appropriate docs)
  45.         - Upon your app crashing, files currently being edited can
  46. automatically be saved out. This of course can only be done if your app
  47. maintains a ready-to-save copy of the file at all times (which is
  48. recommended). (See appropriate docs)
  49.         - You can use the Tornado renderers. These centralised renderers take
  50. a file, in its saved format, and render it. They can render 2d vectors, text,
  51. DTP pages, sound, 3d vectors, bitmaps, soundtrackers, movies - whatever. Once
  52. a renderer is written and installed, it's available for all apps that can
  53. take it (see appropriate docs)
  54.         - You can use the Tornado multiprocessors. Although these are far
  55. more generalised than just for this one, these can convert between file
  56. formats (as mentioned above), but can also do complex tasks eg; rotate a
  57. JPEG. This may be done not only on a local processor, but perhaps on a second
  58. processor or a processor on a machine on the other end of a network see
  59. appropriate docs)
  60.  
  61. (i): Virtual memory works by breaking up very long block into much smaller
  62. ones (usually a multiple of the track size of the disc media upon which the
  63. cache is being kept for speed). Each of these blocks has a time associated
  64. with it (OS_Monotonic) ie; when it was last accessed using Tornado_Getaddr.
  65. When necessary, blocks past a certain age (or type - for example, blocks all
  66. belonging to a 25Mb block will be swapped in and out depending on which part
  67. of the total block is being accessed - thus not flushing all data onto disc)
  68. get dumped to disc and it is stored where they are (disc pathname). This
  69. allows a 2560x2048 32 bit sprite (taking normally 20Mb) to be edited on a 1Mb
  70. machine, as given that there would be an average 75 byte header, and with
  71. 2048 blocks of 10240 bytes each (=2 tracks on floppy E format) = about 170k
  72. of memory + 10240 to store each block.
  73.  
  74. The common tornado heap help in RMA is a special tornado heap, and is
  75. referenced by passing 0 as the heap start to the Tornado heap SWIs. It
  76. features relocatable blocks with auto-garbaging, and fixed blocks are
  77. supported too. Heaps are also relocatable, so you can have a heap in a heap.
  78. Also, heaps can be auto-extending, ie; they will increase/decrease the
  79. allocation of whatever they are stored in. In the case of postslot heaps,
  80. they will automatically call Tornado_ExtendSlot to alter the size of the
  81. heap. This makes setting up postslot heaps extremely easy.
  82.    Blocks in these special heaps are referenced to by their handle, a
  83. negative number. This handle is passed to all heap operations, and the
  84. program need not worry where the data is really stored. When it needs to
  85. access the data, it calls Tornado_Getaddr, which returns the current address
  86. of that block. Fixed blocks are referenced a la OS_Heap style, with the
  87. handle being a fixed address in memory.
  88.    Another heap used by Tornado is the subtask heap, referenced by 1 - but
  89. this is for the exclusive use of subtasks - see the appropriate
  90. documentation.
  91.