Introduction and Overview
The Task Manager is a central component of the RISC OS desktop environment. It provides facilities for monitoring and controlling active tasks, managing memory allocation, and handling system-wide operations such as shutdown and power control.
This chapter documents specific interfaces provided by the Task Manager for handling system acknowledgements and initiating system shutdowns.
Technical Details
Changes to the Task Manager
The TaskManager module has been updated to bring it up to date with the rest of RISC OS. The following changes have been made to the module :
- The TaskManager will warn users when the system is powered off without being safely shut down. This should encourage users to correctly shut down the system, rather than to merely turn off the system. Failure to shut down correctly may result in data loss.
- The 'System memory allocation' details in the main tasks display has had a number of the previously displayed regions removed : Screen memory (no longer centrally allocated; see the 'Video' areas within the 'Dynamic areas' section); Cursor/System/Sound (these are now separate areas, listed under the 'Dynamic areas' section); System heap/Stack (now presented as just 'System heap', as the system stack is a separate area - not listed).
- The 'System memory allocation' details still includes the 'Font cache', 'System sprites' and 'RAM disc' areas, despite these areas now being controlled by the relevant modules (FontManager, SpriteUtils and RamFS respectively).
- Physical dynamic areas are indicated by blue bars rather than red. This indicates that the areas are not part of normal allocatable memory.
- It should be noted that the list of memory regions is not complete. In particular, memory regions allocated to the page tables, to the system stacks and other system areas (for example the softloaded ROM) are not included.
- The memory size allocations beside each region are now listed as megabyte when they exceed 16M (rounded down). This makes the memory allocations easier to read.
- The information window no longer provides a hidden 'cookie' by clicking on the authors field.
- An 'i' icon in the information window provides additional information on the components within the system.
- The shutdown confirmation window will offer 'Restart' and 'Off' buttons. These can be triggered by the 'R' and 'O' keys respectively. The 'Off' option is only available on hardware with power control (see the Portable document).
- The 'Exit' option has been removed from the menu, as it leaves the desktop without an obvious means of returning. Equivalent behaviour can be triggered by using Shift-Ctrl-F12 from the reset banner.
- The configuration applications can be accessed from the TaskManager menu by selecting the 'Choices...' option.
- The menu has an option 'Stand by' which will place the machine into a power conserving state. The power will not be removed, but hardware will be shut down and the system placed into a dormant state. This option is only available on hardware with power control (see the Portable document).
Acknowledgements
The Task Manager maintains a list of software acknowledgements and licences which are displayed in the system information window. The Task Manager broadcasts Service_TaskManagerAcknowledgements to allow modules and applications to register their own acknowledgements.
When a module receives this service call, it should check R2. If R2 is non-zero, it contains the address of a callback routine provided by the Task Manager. The module should call this routine once for each component it wishes to acknowledge, passing pointers to its title and description strings.
If a module's acknowledgements change (for example, if a licence is registered), it should issue Service_TaskManagerAcknowledgements with R2 = 0. This notifies the Task Manager that it should re-issue the service call to re-cache all acknowledgements.
Registering acknowledgements
Many components of the system are required to provide an acknowledgement of their licence to the user. The TaskManager provides a mechanism for this through the Service_TaskManagerAcknowledgements service. It is intended primarily for commercial developers and software built into the OS itself, but may be used by anyone. It is used to allow modules to communicate information about their licences which they are required to state, but would otherwise have no other means of displaying.
The group identifier passed to the registration routine is of the form &GMMM, where G selects the category (0 to 2 being reserved for the operating system vendor, 3 for commercial components, 4 for freeware components and 5 for user components - private use only). The MMM field should be set to 0 and is for future developments.
The registration routine must be called with the following notes in mind:
- Return with MOV pc,link (ie do not preserve the flags).
- Details should be formatted for 60 characters, of LF terminated strings. Try to remember to include full stops at the ends of sentences. Thus, in BASIC, you might use "© Fred Bloggs, 1998."+CHR$10+"© Sue Bloggs, 1999."+CHR$0
You should only call the entry point when requested for information by the TaskManager. TaskManager 0.11 and later support this service. Data will be copied so you can build strings in a temporary area if necessary.
In assembler you might use code something like the following to register messages :
svc_acknowledgements
TEQ r2,#0
MOVEQ pc,r14
STMFD r13!,{r0-r3, r14}
MOV r3,r2
MOV r0,#&5000 ; group id
ADR r1,Title ; pointer to your module title string
ADR r2,CopyrightMessage ; some copyright message
MOV r14,pc
MOV pc,r3
MOV r0,r0
LDMFD r13!,{r0-r3, pc}
CopyrightMessage
= "This software is based in part on work by Diaxos Holdings", 10
= "Incorporated.", 10
= "Some sections have been provided by Wally Williams.",0
In C you might use code something like the following :
typedef void (*addmessages_func)(unsigned int group,char const *title,
char const *message);
#define Service_TaskManagerAcknowledgements 0x42680
void main_service(int service_number, _kernel_swi_regs *r, void *pw)
{
if (service_number==Service_TaskManagerAcknowledgements)
{
addmessages_func func=(addmessages_func)r->r[2];
if (func!=NULL)
{
func(0x5000,Module_Title,"This software is based in part on the work of the Independent\nJPEG Group.");
}
}
}
On module initialisation and finalisation you should notify the TaskManager of the change to the acknowledgement messages by issuing the service with R2 = 0. In C you might do this as :
/* Let TaskManager know it's changed */
_swix(XOS_ServiceCall,_INR(1,2),Service_TaskManagerAcknowledgements,0);
In assembler, this could be :
; Cause a re-cache of the acknowledgements window
LDR r1,=&42680
MOV r2,#0
SWI XOS_ServiceCall
System Shutdown
In order to make shutdown more reliable and allow applications to force a reboot, the Task Manager shutdown controls have been updated. In addition to the standard bits that may be passed to SWI TaskManager_Shutdown, new bits have been defined to provide additional functions.
System shutdown is handled by the SWI TaskManager_Shutdown SWI. This call manages the process of notifying tasks that the system is closing, closing files, and optionally rebooting or powering off the machine.
The shutdown process typically involves:
Service Calls
| R1 | = | &42680 (Service Number) |
| R2 | = | Pointer to callback code, or 0 to notify Task Manager that acknowledgements have changed. |
| R1 | preserved | |
This service call is used to manage the registration of software acknowledgements with the Task Manager.
If R2 is non-zero, the service call is being issued by the Task Manager to gather acknowledgements. Modules receiving this call should call the address in R2 to register their components. Details of this callback can be found in the Acknowledgement Registration Callback section.
If R2 is zero, the service call is being issued by a module to notify the Task Manager that acknowledgements have changed. The Task Manager will respond by re-issuing the service call with R2 non-zero to re-cache all information.
Entry points
| R0 | = |
Group identifier:
| ||||||||||||||
| R1 | = | Pointer to null-terminated component title string | ||||||||||||||
| R2 | = | Pointer to null-terminated acknowledgement details (formatted as 60-character LF-terminated strings) |
| R0 - R12 | preserved | |
This routine is provided by the Task Manager and is called by modules during Service_TaskManagerAcknowledgements (when R2 <> 0).
The module should call this routine once for each component it wishes to acknowledge. The Task Manager will copy the strings pointed to by R1 and R2 into its own buffers.
The acknowledgement details string should consist of one or more lines of text, each terminated by a linefeed (ASCII 10). Lines should ideally be no longer than 60 characters.
SWI Calls
| R0 | = |
Shutdown flags:
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| R0 - R9 | preserved | |
This SWI initiates the process of shutting down the desktop environment. Depending on the flags in R0, it can lead to a reboot, a power-off, or an exit to the command line.