home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 5 / DATAFILE_PDCD5.iso / utilities / t / tornado / TNdemo2 / _TShell < prev    next >
Encoding:
Text File  |  1996-05-29  |  15.6 KB  |  294 lines

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