home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / misc / tornado / tndemo1 / _TShell < prev    next >
Text File  |  1996-02-26  |  15KB  |  251 lines

  1. Tornado shell
  2. -=-=-=-=-=-=-
  3.    These are various notes on the tornado shell, grouped into various topics.
  4.  
  5. The Shell itself
  6. -=-=-=-=-=-=-=-=
  7.    The shell, upon startup, registers itself with the kernel and claims a
  8. large number of SWIs and service calls. It then starts itself up as a wimp
  9. task with a dynamic memory area, and creates the program environment within
  10. its slot.
  11.    Within the user code which polls the Wimp, there is a section of code
  12. which interfaces with the RISC-OS Wimp (manages window redraw requests from
  13. the Wimp, mouse and keypresses from the Wimp etc). It also performs dynamic
  14. system performance optimisation, and calls the interrupt code responsible for
  15. multitasking the tasks. To this it passes a stack, through which it runs,
  16. calling each task in turn for whatever amount of time.
  17.    Depending on user preferences, CPU power available, the load on the
  18. RISC-OS Wimp, the load on the tornado multitasker etc, control may be passed
  19. back to the RISC-OS Wimp without cycling all of the tasks/processes. This is
  20. done to prevent the RISC_OS Wimp becoming jerky, because as shown below total
  21. turnaround may take up to a second.
  22.  
  23.  
  24. Multitasking
  25. -=-=-=-=-=-=
  26.    The preemptive multithreading task switcher employed by the tornado shell
  27. currently performs the following:
  28.  
  29.    * It aims to turnaround all of the tasks (ie; give control to all tasks)
  30. in 50cs, or half a second. This value can be altered by the user to a fixed
  31. value, or more appropriately tornado can be allowed to manage the value
  32. itself, allowing it to vary between 10cs and 100cs, updated dynamically to
  33. reflect the current system's requirements.
  34.  
  35.    * Each task has a priority value attached to it which is between 0 and
  36. 255, with 64 being average. The total turnaround time is divided up into
  37. weighted parts according to their relative priorities. The maximum priority a
  38. normal task may have is 192, and the lowest 1. A priority of 0 means the task
  39. does not have any user code it wants multitasked.
  40.  
  41.    * After the times given to each task have been decided, the task swapping
  42. starts. For each task, the following happens:
  43.  
  44.     (i): Current time is noted from OS_ReadMonotonicTimer, and a callback
  45. scheduled in whatever the time allocated to this task is.
  46.    (ii): Task's memory is paged into &8000, with its private heap into
  47. &808000. As you can see, this limits program size to 8Mb, and far worse is
  48. file size is also limited to 8Mb. However, there is no reason why on later
  49. machines the entire program image and heap cannot be shifted to outside the
  50. 32Mb boundary, leaving a page at &8000 so things hopefully wouldn't fall
  51. over for the language. Worst case scenario is that only the program size will
  52. be limited to 16Mb, which in any case is the same as RISC-OS, so however they
  53. get around it so will tornado. Personally, I still can't see why they didn't
  54. kill all those restrictions and do it properly, but then I guess I'm only one
  55. bloke compared with all the wisdom (and expertise) of Acorn! ;)
  56.   (iii): Tornado checks what the user is doing, and does whatever the visual
  57. commands currently known to it dictate (start new threads, pass information
  58. to a thread or ticker, whatever).
  59.    (iv): Whatever redraw threads for this task are kicked in, with each
  60. thread getting 1cs of time. Note that threads may create new threads, either
  61. in the task or new redraw threads themselves.
  62.     (v): Assuming we still have some time left (which may not be true, in
  63. which case the program itself doesn't get control this cycle), each of the
  64. threads running in the program are given 1cs of time until this task's
  65. allocation runs out, or else threads are given weighted divisions of the
  66. time left depending again on system performance and/or user preferences.
  67.    (vi): Next task.
  68.  
  69.    The task is monitored constantly. Every second an interrupt routine
  70. sitting on a ticker checks to see preemption is working correctly. If for
  71. some reason the callback system has stopped, a forced termination is made.
  72. This is quite powerful - only disabling interrupts can stop it. To the user,
  73. a box will appear saying that the task seems to have crashed and asking what
  74. to do. Meanwhile, multitasking on other threads/tasks continues.
  75.    Facilities are also provided for hogging the processor. A task may request
  76. complete control of the processor, and it will get it if it's enabled.
  77.  
  78.    You will notice that on slower machines most of the CPU time will be spent
  79. switching tasks and doing housekeeping. I have managed to get preemptive
  80. multithreading redrawing working on a test program, and let me tell you it
  81. sure *is* slow. The desktop moves quite fluidly, but boy is it slow.
  82.    The above method ensures a very flexible and powerful method of CPU
  83. sharing, but it is subject to cascade overload ie; the more things are going
  84. on, the more time is spent in switching between them, and as you can see
  85. there comes a threshold when simply the switching alone is enough to fill
  86. quotas, and before you know it the turnaround time is exceeded.
  87.    Tornado, if enabled, will then adjust the turnaround time to get all the
  88. tasks in. It will not let tasks go without control for long periods, so
  89. serial programs etc will be kept up to date well-enough (although no data
  90. will be lost as there are two dynamically controlled pipes managed by
  91. interrupt code on every i/o device, in addition to another two individual
  92. dynamic buffers for every task doing i/o).
  93.    However, should the turnaround time exceed 25% of the specified time, or
  94. greater than 100cs when it is automatically controlled, tornado will begin to
  95. warn you that the system is becoming overloaded and you should shut down a
  96. few tasks.
  97.    The only likelihood this will happen is during CPU intensive operations.
  98. You could be using a hires mode without VRAM, and printing multiple files
  99. while moving a lot of windows around will increase the number of processes
  100. exponentially, thus causing cascade overload.
  101.    Obviously, the warning option can be disabled, as multiple warning windows
  102. piling up is just increasing the number of processes, making the situation
  103. worse.
  104.  
  105.    Another little thing to note is that due to there being two types of
  106. interrupt on Acorn machines - FIQ and IRQ - with one of those virtually
  107. unused as it is too 'strong' - there is little chance to make one interrupt
  108. more 'stronger' than another - which means tornado has to use the same level
  109. of interrupt as more important things like hard discs and the serial port.
  110. Ie; a heavily loaded system may cause tremendous serial access problems
  111. especially, but hopefully hard disc access for most disc controllers will be
  112. unaffected as these aren't so time-critical. It's like running a lot of task
  113. windows while doing serial i/o direct to the HD at high speeds - corruption
  114. occurs (or at least it does on my (older) machine). Preemption relies
  115. intrinsically on interrupts, and while a minimum of code is executed with
  116. interrupts disabled, more switching means more time the computer has no
  117. interrupt servicing abilities ie; the serial port or hard disc can go
  118. unanswered for lengths of time which may cause overruns.
  119.  
  120.  
  121. Look
  122. -=-=
  123.    Tornado in look and feel is right up there with the most modern. It uses
  124. true colour throughout, right from window definitions to multi-bitdepth
  125. bitmaps and will render for the current screen being used by the Wimp.
  126.    Obviously, it will work at its best on the later computers with large
  127. amounts of memory, fast hard discs and true colour displays. Unlike RO3.5 it
  128. has built from the bottom to use outline fonts and dithered and textured
  129. backgrounds. Unlike RO3.x, textures show through text, not leaving a blanked
  130. box around each character. Unlike RO3.x, tornado has a considerably enhanced
  131. user interface instead of one which has been built and bodged from the
  132. eighties - things like true-colour graphics, quick-look status and attribute
  133. icons, animation, sound-effects and a common shared set of interface
  134. utilities will ensure it becomes the de facto interface for all platforms.
  135.    While older computers will have the true-colour sprites scaled down to
  136. suit whatever display they're using, newer computers will render them in
  137. their true quality. Animation is used even in little circumstances like the
  138. toggling of a button - instead of the boring inversion from one to the other
  139. extreme, tornado displays a few levels in between depending on user
  140. preferences and/or CPU speed. Sound-bytes can be attached to such switchings,
  141. thus adding a degree of personalisation not heard of before on RISC-OS.
  142.    Thanks to someone on usenet suggesting this, I have decided a common set
  143. of interface utilities would be nice. His idea was to have an extension which
  144. can be replaceable ie; a slider could be replaced with a turnable knob and
  145. the program underneath need never know. These should be fully customisable
  146. and so more personalisation is possible.
  147.    Another suggestion from usenet was multiuser capability. This again will
  148. be managed by tornado, not involving individual applications, and will allow
  149. a user to lock off parts of a hard disc, and have its own preferences for
  150. each application. This extends to startup files and initial displays.
  151.  
  152. File manager
  153. -=-=-=-=-=-=
  154.    The file manager is a special task which runs under the shell. Its purpose
  155. is to provide management for files, allowing them to be shared between tasks,
  156. and to provide i/o interfaces for/to devices.
  157.    The core of the file manager is interfacing with and manipulating 'data
  158. streams'. Normally, streams of data are piped between different processes by
  159. the shell and multitasker, and can split into two or more seperate streams
  160. at any particular junction. All of this happens automatically, regulated by
  161. the shell.
  162.    The file manager extends the usefulness of these streams greatly. Normally
  163. streams are inter-process only, and never leave RAM or for that matter the
  164. tornado environment. The file manager allows streams to be piped into
  165. physical devices like disc drives, serial ports, printer ports etc.
  166. Therefore, the output of a process can go directly to a printer for printing
  167. (more later).
  168.    Also, it takes the responsibility for the manipulation of files. When a
  169. user drags a file onto a task, the file manager loads it and gives the task a
  170. 'view' of the file. At all times, the file is maintained and held by the file
  171. manager.
  172.    However, this is not to say that files cannot be loaded by tasks by
  173. themselves. In such a case, no eye would be present (see below).
  174.    The shell provides hook-ins for the file manager, and essentially they are
  175. part of each other (like Fileswitch and the kernel in RISC-OS). For the
  176. purposes of development they are currently seperate, but may be integrated
  177. together at a later stage.
  178.    As part of the data streaming methodology, icons are added to the title
  179. bar of each window. The first on the right is what owns the window - usually
  180. it will be a mini version of the task's icon. The others indicate what the
  181. direct contents of the window are, what is directly linked to this window
  182. etc. For example: an arrow pointing to a black hat means that the contents of
  183. the window are being fed into a converter. Clicking Menu on these will
  184. produce a small list - for example, the output of the convertor might be
  185. going into another convertor, or might be being spliced off into a viewer, or
  186. temp file, or being printed, or whatever really.
  187.    An open eye represents a view of a file held by the file manager. A closed
  188. eye represents a view of a physical device eg; printer, monitor or keyboard.
  189. So:
  190.  
  191. -> hat -> hat -> hat -> closed eye
  192.               |
  193.                -> open eye
  194.  
  195. This would be produced by menu on an arrow and hat on the title bar. However,
  196. an arrow and hat may also be displayed beside a file icon in the filer window
  197. (not easy to do). The file in the filer (say a JPEG) then would be being
  198. converted to a PBM, which is then being converted to a Sprite, which is then
  199. being converted to printer commands, and then sent to the printer to be
  200. printed. However, another tornado application has been asked to view the
  201. Sprite, whether by the user or automatically by tornado (eg; the user
  202. double-clicks on the JPEG file while it is still being printed - rather than
  203. reconvert it, the currently happening conversion is used). In this window, as
  204. the file is converted, the currently converted image is displayed, and is
  205. updated as necessary.
  206.    All of this happens while multi-tasking. The convertors also
  207. multi-process, converting what the previous convertor has processed ie; they
  208. don't wait until the previous process finishes. The converter before the
  209. printer converts the sprite into printer commands, and stores this on disc.
  210. Simulataneously, tornado copies the file, under interrupts, to the printer
  211. (wherever it is). This allows the convertors to print quicker than the
  212. printer can - thus not having processes run longer than necessary.
  213.    BTW, this idea came to me when I was thinking about what Justin Fletcher
  214. said in his docs on the AU cover disc a while back during Irish class - I
  215. still have my notes written into the back of my homework journal! Thanks
  216. Justin!
  217.  
  218.  
  219.  
  220. Hardware requirements
  221. -=-=-=-=-=-=-=-=-=-=-
  222.    Originally, I said that tornado wouldn't need more than a 1Mb floppy-only
  223. Arm2 RO2 machine. This was a long time ago, before tornado even had a
  224. multitasker!
  225.    Now, with the current specification, a minimal usable setup would be 2Mb
  226. 20Mb HD RO2 Arm2. This, I stress, is minimal. On such a machine, you would
  227. have limited use as resources would be so stretched.
  228.    However, tornado *will* adapt to its surroundings. It will vary its
  229. multitasking for slower computers, alter its memory usage when memory becomes
  230. tight, and make whatever use of the hard disc(s) available depending on space
  231. free on them and how fast they are.
  232.    Technically speaking, tornado /could/ still work on a 1Mb floppy-only Arm2
  233. RO2 machine, but you wouldn't have any virtual memory, file sharing, and
  234. multitasking would be restricted to say the least. Also, there would be so
  235. little memory available that possibly the only use of tornado in such
  236. circumstances would be as a demo! (and a poor one at that!).
  237.    A more optimal setup would be a 4Mb 100Mb HD RO2 Arm3 machine. On this
  238. machine, tornado's full facilities would be available, although less
  239. effective because of lack of RAM and CPU speed. A fast empty hard disc here
  240. would be ideal as tornado will put little-used buffers and caches onto disc
  241. where possible, stretching to whole or part of files when necessary. This
  242. minimises the RAM required, although it will put a greater load on the CPU.
  243.    The obviously best setup is an infinite memory machine with an ArmX00
  244. series CPU, large fast empty hard disc, and a hires 24 bit display. This
  245. allows tornado to forsake colour, sprite and icon translation and plot
  246. straight into screen memory, making things faster still. The fast CPU allows
  247. a quick turnaround of tasks, with little waste on housekeeping and task
  248. switching code, leaving more for each thread's code. Tornado can also gobble
  249. memory and disable its 'intelligent' memory-saving routines, saving on more
  250. unnecessary code being executed still.
  251.