Task Prioritization and Run Time Management

Applies To: AutoMate 6, AutoMate 5
Published: 9/27/07 , modified December 19, 2007

Introduction
AutoMate has the ability to execute numerous tasks simultaneously. The total amount of simultaneously run tasks can be configured from the Task Administrator under 'System' -> 'Options' -> 'Priorities' tab.

On the other hand, there are certain situations when a task may need to run independent and uninterrupted from all other tasks in some manner. For example, such an option is useful when an interactive task must make sure that a particular window stays in the foreground in order to send keystrokes to it. If another task were to run and try to focus an unrelated window, it would eventually interfere with the task that is attempting to send keystrokes, thus failing one, or possibly both tasks. Additionally, a developer may wish to limit the number of simultaneously running tasks. For example, this is a useful option if trying to limit the amount of system resources (i.e. CPU and memory usage) utilized.

Besides the prioritization options in AutoMate, tasks that are currently placed in a queue or tasks that are currently running can be controlled or managed as well.

This article will provide details regarding AutoMate's Task Priority feature as well as provide information regarding management of tasks that are currently placed in a queue or tasks that are currently in a running state.

Task Priority
The Priority feature in AutoMate provides the capability to essentially set priority levels to a managed task. When this option is used, AutoMate can be instructed whether or not to run a task in concurrence with other tasks, and how to handle a conflict if one takes place between tasks. The Priority settings are located in the 'Managed Task Properties' window of each task under the 'Priority' tab.
Task Prioritization is comprised of two essential elements, under what conditions the task will not be allowed to run (Priority Condition) and what to do with the task if such a condition occurs (Priority Conflict Action).

Priority Condition
Task priority can be set for the following four conditions:

- Always Run
The task is free to operate alongside other tasks, and runs without checking any priority conditions. However, this does not make it impervious from being suspended, stopped or queued by another task that has already begun with priorities that conflict with this task. For example, if a task with priority settings 'Run Alone' has already started, the task set to 'Always Run' will not immediately execute but rather have to wait in a queue assuming the conflict action "Hold task indefinitely" is selected (see below)

- Limit number of simultaneous instances of this task
AutoMate checks if running the current task will cause the total number of running tasks with the same name to exceed the specified value selected under the option "Max number of running tasks." If so, AutoMate uses the selected priority conflict action (see below).

- Limit number of simultaneous tasks
AutoMate checks if running the current task will cause the total number of running tasks to exceed the specified value chosen under the "Max number of running tasks" option. If so, AutoMate uses the selected priority conflict action (see below).

- Run Alone
The task only runs if there are no other tasks running (this is equivalent to the priority condition "Limit number of simultaneous tasks" with the total allowable tasks set to 1.)

Priority Conflict Action
When a task cannot run because its priority condition is not met, the task is either ignored and never run, or placed into a queue of waiting tasks. The queue is examined each time a running task ends, and priority conditions of each queued tasks are reevaluated to see if the task can now be run. Available priority conflict actions are as follows:

- Hold task indefinitely
The task is placed into the "waiting tasks" queue until all other prioritized tasks have completed. Then, the task is taken finally taken out of the queue and runs.

- Hold task then abort
The task is placed into the "waiting tasks" queue and waits for the amount of minutes specified. If the time elapses before conditions change that allow the task to run, the task is automatically removed from the queue and discarded. If a 'Schedule Watcher' trigger initially launches the task, it is rescheduled based on the 'Schedule Watcher' trigger's re-scheduling properties.

- Hold task then interrupt all running tasks
The task is placed into the "waiting tasks" queue and waits for the amount of minutes specified. If the time elapses before the change to allow the task to run, all the tasks currently running on the system are forcibly stopped (aborted), and the current task begins immediately thereafter. When used in conjunction with the 'Run Alone' priority condition, this provides a task the highest possible running authority.
- Interrupt all other running instances of this task
All tasks with the same name as the currently running task are interrupted and the current task begins immediately.

- Don't run
The task does not run at all. If a 'Schedule Watcher' trigger is set to launch the task, it is re-scheduled based on the trigger's re-scheduling parameters.

Managing Queued and Running Tasks

AutoMate tasks can be stopped at any time by holding down the CTRL-ALT-END keys simultaneously. This will immediately pause all running tasks and display the AutoMate Running Tasks dialog which shows currently running tasks and provides options to stop one or all tasks.

Tasks that have been queued by a prioritized task also appear in AutoMate Running Tasks window. Queued tasks are marked as "Queued" in the 'Status' column. From this location, you have the option to remove a task from the queue or force a queued task to immediately run. The queued task(s) management options are listed below:

- Forcing a queued task
To force a queued task out of the queue and run immediately, right click on the desired task name and select Force Task.

- Removing a queued task
To remove a task from the queue without running it, select the desired task name and click End Task. Multiple queued tasks may be selected by holding down the CTRL key while selecting tasks.

- Ending all tasks and clearing the queue
Click the End All button. All running tasks will stop immediately and the queue will be cleared.