home *** CD-ROM | disk | FTP | other *** search
/ Acorn User 4 / AUCD4.iso / acornuser / 1998 / apr1998 / pd / Avison / !TaskUsage / !Help next >
Text File  |  1998-02-12  |  18KB  |  388 lines

  1.  
  2.                        Help for Task Usage                        Version 1.15
  3.                        ===================                        © Martin Avison
  4.                                                                   Avisoft
  5.   Purpose
  6.   =======
  7.  
  8.   The purpose of this little application is to display in figures and graphically:
  9.  
  10.   •    the recent average processor usage for each Task
  11.   •    the recent average processor usage for each Wimp Reason Code
  12.   •    the number of Wimp Polls being processed
  13.  
  14.   The Reason Code and Poll details can be for all Tasks, or for a specific Task.
  15.   If for a specific task, any Reason Codes masked out by the task are shaded.
  16.  
  17.   This is all done with as little overhead as possible.
  18.  
  19.   The idea grew from a theory that some tasks seemed to take more processing power
  20.   than they should, either permanently or intermittently, making the desktop
  21.   sluggish.  The main causes seems to be programmers simple mistakes, or
  22.   programmers being lazy, and ignoring the exhortation in the Programmer's
  23.   Reference manual, page 3-116:
  24.  
  25.        "You can disable some of the event codes: they are neither checked for
  26.        nor returned, and need not have any handlers provided.  You must do this
  27.        for as many codes as possible, especially the Null_Reason_Code, if your
  28.        task is to run efficiently under the Wimp."
  29.  
  30.   PLEASE TAKE NOTE!  With the help of TaskUsage we all now have NO excuse!
  31.  
  32.  
  33.   How to use TaskUsage
  34.   ====================
  35.  
  36.   The TaskUsage application is started in the normal way by double-clicking on
  37.   the !TaskUsage icon in a Filer window.  It will install on the Icon Bar a
  38.   TaskUsage icon consisting of a box containing 'CPU'.   However, after a small
  39.   delay to collect initial statistics, the TaskUsage Icon Bar icon will be updated
  40.   each second or two with a graphical representation of the total processor usage.
  41.  
  42.   The update time will be one second for RISC OS 3.5 and above (ie at least RISC
  43.   PC), and two seconds for the slower machines to avoid a large display overhead.
  44.   This default should be reasonable, but the default can be overridden if
  45.   required  (please see the !Run file for details)
  46.  
  47.   The Icon will normally show the usage over the last 40 seconds or so.
  48.  
  49.   If Select is clicked on the TaskUsage icon bar icon, the Task Processor Usage
  50.   window will open.  This window is in a similar format to the Task Manager's
  51.   display of Storage usage, showing the current tasks, and in the same order.
  52.   Against each task is shown the recent average percentage processor usage, as a
  53.   percentage figure and a coloured bar graph.  In addition, the overall Processor
  54.   usage is given, and the totals for Application and for Module tasks.  The
  55.   display will update every second or two, and will adjust itself whenever tasks are
  56.   started or stopped.  The window can be resized in the usual RISC OS way, but if
  57.   Select is clicked on the Icon Bar the window will revert to the initial state,
  58.   showing all Application Tasks, and only the total for the Module Tasks.
  59.  
  60.   If Adjust is clicked on the TaskUsage icon bar icon, the Task Reason Code
  61.   Usage window will open.  This shows the recent average number of Wimp Polls
  62.   being processed per second, and the processor usage for each Wimp Reason code.
  63.   If a task is clicked on in the Task Processor Usage window, the Task Reason Code
  64.   Usage window will change to show the figures for that task only.  While a
  65.   specific task is being monitored, any Reason Codes which the task has masked out
  66.   because it is not interested in them are shaded.  To revert to monitoring all
  67.   tasks, simply click on any totals line in either window.  Note that the Reason
  68.   Code shading cannot be updated until the task does something, however trivial.
  69.   This is prompted by TaskUsage sending the task a Wimp_HelpRequest message, which
  70.   is usually sufficient.  If all the reasons remain shaded, try opening a menu or
  71.   a window for the task.  Unfortunately, if the Filer is clicked on, you may get
  72.   an error message from the Filer of 'Message token MH not found'.  This will stop
  73.   happening if a menu is opened over any Filer window!  And before you ask, I do
  74.   not know why!
  75.  
  76.   If Menu is clicked on the TaskUsage icon bar icon (or on either TaskUsage
  77.   window), the usual Info and Quit options are available.  In addition there is
  78.   a Timer option, which just shows details of the Timer being used and the Update
  79.   frequency, and Task and Reason options which will also open the windows.
  80.  
  81.   Note that full Interactive Help is available on all Menus and Windows, if !Help
  82.   or !BubbleHelp is running.
  83.  
  84.  
  85.   Machine Requirements
  86.   ====================
  87.  
  88.   Any measurement will distort what is being measured, and Task Usage is no
  89.   exception.  However, the overheads have been pared to a minimum to enable it
  90.   to be run easily on any RISC OS machine.
  91.  
  92.   Note that at least RISC OS 3.00 is required to run TaskUsage.
  93.  
  94.   The memory requirements are approximately as follows:
  95.  
  96.   •    The TaskUsage relocatable module           6,192
  97.   •    The TaskUsage module workarea              6,272
  98.   •    The Messages file                          1,848
  99.  
  100.                           Total Storage          14,312
  101.  
  102.   The total storage required to run Task Usage is therefore only about 14k, all in
  103.   the Relocatable Module Area, regardless of the machine model and page size. 
  104.   Some 5k or so additional storage will also be obtained by the Wimp in the RMA to
  105.   hold window definitions etc. for the Task Usage application.
  106.  
  107.   Task Usage measures it's own task, which uses on average the following
  108.   processor power on two machines, with both windows open, even with over
  109.   100 tasks running. Note it is even less without the windows open!
  110.  
  111.   •    RISC PC with StrongArm        less than 1% processor
  112.   •    A4000                         varies between about 10% and 30%
  113.  
  114.   RmKill TaskUsage can be safely used to remove the module from storage.
  115.   Quitting the TaskUsage application will do this automatically.
  116.  
  117.  
  118.   How the Processor Usage is Calculated
  119.   =====================================
  120.  
  121.   When TaskUsage initialises, it installs the following timing code in RISC OS:
  122.  
  123.   •    The internal Timer 1 is used to obtain all elapse times.  This requires
  124.   interrupt code, which is only 6 instructions long, but it is called many times a
  125.   second, depending on the 'precision' of the timing clock being used.
  126.  
  127.   !TaskUsage automatically sets the precision depending on the RISC OS version,
  128.   and whether StrongArm is fitted.  This is so that faster processors can use a
  129.   higher precision timer, but slower processors are not spending too much time
  130.   trying to be over accurate!  The default settings should be reasonable, but the
  131.   default can be overridden if required (please see the !Run file for details)
  132.  
  133.       Precision     Timers/Sec          Default used
  134.           0            100
  135.           1            200
  136.           2            400              v3.00, v3.10, v3.11
  137.           3            800
  138.           4          1,600              v3.50, v3.70 (ie RISC PC)
  139.           5          3,200
  140.           6          6,400              v3.70 with StrongArm
  141.           7         12,800
  142.           8         25,600
  143.  
  144.   The higher the precision, the more accurate, but the more overhead!!
  145.  
  146.   This internal Timer is used in preference to the RISC OS Monotonic Time,
  147.   because that is only available in centiseconds.  A StrongArm machine can poll
  148.   at 20,000 times a second, so using a timer which is only capable of measuring to
  149.   100 times a second is rather inaccurate!   Note however that there can be only
  150.   one user of Timer 1 - if you have another Application which uses Timer 1, then
  151.   if they are both running at the same time, the first one started will NOT work
  152.   properly.  If you need to run both applications, then using a precision of M will
  153.   set TaskUsage to use the Monotonic Time (100 Timers/sec) instead of Timer 1.
  154.  
  155.   The precision and the timer being used can be displayed by the menu option Timer.
  156.  
  157.   When TaskUsage initialises, it installs the following monitoring code in RISC OS:
  158.  
  159.   •    The Wimp Post-Filter code, which is about 12 instructions long, and is
  160.   called every time a program returns from a Wimp Poll.
  161.  
  162.   •    The Wimp Pre-Filter code, which is about 33 instructions long, and is
  163.   called every time a program calls Wimp Poll.
  164.  
  165.   •    The Interrupt code, which is called every second (or two), is about 230
  166.   instructions, plus 10 for each of the maximum number of tasks that have run
  167.   concurrently since the computer has been started or Reset.
  168.  
  169.   Using the times gathered by this monitoring code, the following are calculated:
  170.  
  171.   •    The elapse time is recorded for each Task, from the time when the
  172.   application is returned to after calling WimpPoll, to the time the application
  173.   calls WimpPoll again.  This is the elapsed time spent in the application Task.
  174.   It will usually comprise Processor time, but if any input or output is involved,
  175.   there may be some time spent waiting for the disc or other device.
  176.  
  177.   •    In addition, each second the interrupt routine first accumulates the time
  178.   for the Task and Reason Code which it has interrupted.  It then calculates the
  179.   latest average for each Task, and for each Wimp Reason Code.  The average is a
  180.   simple rolling 'average', calculated by taking the last average, adding the
  181.   latest elapsed processor time, and dividing by two.  It is not a true average,
  182.   but it is simple, quick, and gives a reasonable representation of the usage.
  183.  
  184.  
  185.   Test Programs Supplied
  186.   ======================
  187.  
  188.   In the !TaskUsage directory there is a directory called TestProgs.
  189.   This contains four simple programs:
  190.  
  191.   •    PollAsm      an Assembler WimPoll loop on NullPoll
  192.   •    PollBasic    a BASIC WimPoll loop on NullPoll
  193.   •    PollIdleBa   a BASIC WimPollIdle loop on NullPoll with 1/10 second delay
  194.   •    PollModule   an Assembler WimPoll loop on NullPoll in a Relocatable Module
  195.  
  196.   Note that all these programs appear to do NOTHING when double clicked on.
  197.   No icons appear!  They simply poll as fast as possible.
  198.   The only way to stop them is to select Quit from the Task Manager display.
  199.  
  200.   Some test results from monitoring the Polling programs, with little else
  201.   running, on two different machines, are as follows:
  202.  
  203.   RISC PC600 StrongArm   RISC OS 3.70
  204.   -----------------------------------
  205.  
  206.   Precision         5
  207.   Timer Used        Timer 1
  208.   Timers/Second     6,400
  209.   Seconds/Update    1
  210.  
  211.                      CPU Usage/Task                Polls/Second
  212.   Programs          1 Task   2 Tasks             1 Task   2 Tasks
  213.  
  214.   PollModule           22%      10%              18,500    5,700
  215.   PollAsm              20%       5%              18,400      800
  216.   PollBasic            60%      15%              11,800      590
  217.   PollIdleBa            0%       0%                  10       10
  218.  
  219.   A4000   RISC OS 3.10
  220.   --------------------
  221.  
  222.   Precision         2
  223.   Timer Used        Timer 1
  224.   Timers/Second     400
  225.   Seconds/Update    2
  226.  
  227.                      CPU Usage/Task                Polls/Second
  228.   Programs          1 Task   2 Tasks             1 Task   2 Tasks
  229.  
  230.   PollModule            8%       4%                 750      200
  231.   PollAsm               8%       4%                 750      180
  232.   PollBasic            45%      15%                 400      130
  233.   PollIdleBa            4%       4%                  10       10
  234.  
  235.  
  236.   Observations from using TaskUsage
  237.   =================================
  238.  
  239.   •    If RISC OS is not operating in multi-tasking mode, for example when F12 is
  240.   used for a command line, or when a program is run which does not call Wimp Poll,
  241.   then the figures collected will be (very) distorted, but will soon recover when
  242.   multi-tasking is resumed.
  243.  
  244.   •    The time spent in applications either before the first call to WimpPoll,
  245.   or after the return from the last WimpPoll, are not included in the times shown
  246.   by TaskUsage, as they are not then multi-tasking.
  247.  
  248.   •    The time spent by RISC OS itself when not actually running tasks is not
  249.   included in the times shown by TaskUsage.
  250.  
  251.   •    Any interrupt code is included in the application which happens to be
  252.   running at the time, but this should be small.
  253.  
  254.   •    The number of Wimp Polls which are being processed per second tends to
  255.   grow, then fall, as the system gets busier, as it can service each task less
  256.   frequently.  Note that a large Null Reason Code time is not necessarily bad: it
  257.   may show that the system has some spare time to do any background tasks
  258.   required.
  259.  
  260.   •    On a RISC PC 600, an assembler loop round a Wimp_Poll in an Application
  261.   Task can manage over 1,600 polls per second, and uses about 10% of the
  262.   processor, if running on its own.  However, if another is started, the total
  263.   drops to about 500, and each task is getting about half.  The total drop must be
  264.   because of the overheads of running more than one application task, which
  265.   requires memory to be paged in and out.  The system polling capability is then
  266.   divided by the number of tasks running.  Subsequent additional tasks do not
  267.   reduce the total significantly, but each task only gets it's share of Null
  268.   Polls.  This is why misbehaved tasks which use the Null reason code when not
  269.   required soak up such large amounts of processor time, making the system less
  270.   responsive, even though Null codes are processed with the lowest priority.
  271.  
  272.   •    On a RISC PC 600, an BASIC loop round a Wimp_Poll can manage about 650
  273.   polls per second, and uses about 55% of the processor, if running on its own.
  274.   However, if another is started, the total drops to about 350, and each task is
  275.   getting about half.  The drop of the total is less than with the assembler Poll,
  276.   but this is probably because the multi-tasking overheads are partly overshadowed
  277.   by the Basic overheads. Again, each task gets it's share of the Null Polls.
  278.  
  279.   •    On a StrongArm RISC PC, the assembler Wimp_Poll loop can reach 19,000
  280.   polls per second, and the Basic loop can reach 1,550.
  281.  
  282.   Some observations on a few specific applications is as follows:
  283.  
  284.   •    !PCpro, version 2.03, supplier Aleph 1:  This uses 90%+ if the PC window
  285.   is open, and has the input focus. This falls to 60% if it does not have the input
  286.   focus, and 0% if frozen. If in full screen mode, it is obviously 100%.
  287.  
  288.   •    !Usage, dated 30/1/92, supplier Acorn:  This sometimes uses up to 30%,
  289.   although it does not report the high usage!
  290.  
  291.   •    !OmniDesk, version 1.10, supplier Acorn User: Exhibits large amounts of
  292.   Null Poll processor time.  It appears that the author planned to use PollIdle
  293.   to poll once a second, as all the code it present apart from passing the time to
  294.   Wimp_PollIdle.  This applies to IconFlags, SWIIndex, and WindFlags.
  295.  
  296.   •    !Larger, version 2.14, supplier Warm Silence Software: seems to use
  297.   WimpPollIdle with a zero time in some cases (eg when a window had been dragged)
  298.   until a mouse click is done on the !Larger backdrop.  Then the time is set to 25
  299.   centiseconds, and the usage drops considerably.
  300.  
  301.   •    !FireworkzPro, version 1.30/06, supplier Colton Software: uses large amounts
  302.   of Null Poll processor time, even when just loaded on the Icon Bar.
  303.  
  304.   •    !EasyFontPro, version 4.13a, supplier Fabis Computing: uses large amounts
  305.   of Null Poll processor time, even when just loaded on the Icon Bar.
  306.  
  307.   These observations may not be typical - or even accurate!
  308.   No criticism of the software is expessed or implied.
  309.  
  310.  
  311.   Acknowledgements
  312.   ================
  313.  
  314.   To Ran Mokady, for the initial inspiration for this !TaskUsage application.
  315.   I obtained his !Usage application, version 1.00, dated 24th May 1990, from
  316.   The Datafile.  However, it tended to lose storage, and it had a relatively high
  317.   processor overhead.  As there was no contact information for Ran, I decided to
  318.   try and improve on it.
  319.  
  320.   To Dominic Symes, for Zap, a wonderful editor.
  321.  
  322.  
  323.  
  324.   Conditions of Use
  325.   =================
  326.  
  327.   Please note that all the software and documentation supplied with TaskUsage is
  328.   copyright, and may only be copied for personal backup purposes.
  329.  
  330.   Although TaskUsage is believed to be free of any bugs, Avisoft cannot accept
  331.   any responsibility for any loss or corruption of data which might result from
  332.   using TaskUsage.  Normal testing and data backup should be performed!
  333.  
  334.  
  335.   Problems and Suggestions
  336.   ========================
  337.  
  338.   If any bugs or problems are found, or if you have any suggestions for
  339.   improvements, please send me full details including version information,
  340.   preferably on eMail, so that I can recreate the problem and try to correct it.
  341.  
  342.  
  343.   History
  344.   =======
  345.  
  346.   v0.??  15/ 5/96  All v0 were development versions, never released.
  347.          It started as a BASIC program with a small Relocatable Module, and was
  348.          gradually changed to a full Relocatable Module Wimp Task, using
  349.          BASIC assembler.  This was to reduce storage requirements, and to eliminate
  350.          the memory switching overhead when TaskUsage became active.
  351.  
  352.   v1.00   9/03/97  Allowed Monotonic Time from parm
  353.   v1.01   9/03/97  Added Timer display dialog box
  354.   v1.02  11/03/97  Fixed time data precisions
  355.   v1.03  20/04/97  Allowed parm to vary PollIdle and Display time
  356.   v1.04  09/05/97  Displayed PollTime in Timer dialog box
  357.   v1.05  25/05/97  Corrected initialisation mask and LastTimer problems
  358.   v1.06  20/08/97  Reduce Wimp Title to avoid old RISC OS problem
  359.   v1.07   9/09/97  Made menu persistent if adjust pressed
  360.   v1.10  14/12/97  First version released
  361.   v1.11   1/ 2/98  Catered for Nested Window Manager
  362.   v1.12   7/ 2/98  Tidied up Templates and Template handling
  363.   v1.13   9/ 2/98  Optimised FNgettime and parameter setup
  364.   v1.14  10/ 2/98  Reduced stack size
  365.   v1.15  11/ 2/98  Reduced Reason time list
  366.  
  367.   Contact Information
  368.   ===================
  369.  
  370.   eMail:      support@avisoft.force9.net
  371.  
  372.   SnailMail:  Martin Avison,
  373.               Avisoft,
  374.               16  Well Close,
  375.               Leigh,
  376.               TONBRIDGE,
  377.               Kent      TN11  8RQ
  378.  
  379.   Phone:      01732 833549
  380.  
  381.  
  382.  
  383.     *******************************************************
  384.     **  If this help has flashed past too fast to read,  **
  385.     **  then please load !Edit and try again!            **
  386.     *******************************************************
  387.  
  388.