By default, task executers handle tasks using FIFO logic (first in, first out). They simply complete tasks in the order in which they were received and added to the task executer's task queue. However, you can make task executers work on more important tasks before less important ones using priority levels, preemption, labels, lists and/or other conditional logic.
Priority levels are numbers or labels you can assign to a task to make one task more important than another.
Preemption determines whether a task executer will be interrupted from its current task to work on a more important task or not. It also affects what happens to the active task that was interrupted. For example, the preemption can determine whether the active task is restarted from the beginning after the preempting task is complete or whether the task should be deleted entirely.
The following are examples of some scenarios in which priorities and preemption systems might be needed:
The rest of this topic will explain important concepts and different methods for creating priority and preemption system.
The following sections will explain how to add task priorities if you are using standard 3D logic:
By default, all tasks have a priority value of 0 unless you assign a different priority level to them. Tasks with larger priority numbers will be completed before a task with a lower priority number. For example, a task with a priority of 10 will be completed before a task with a priority of 1.
The deeper meaning or strategy behind the priority numbers is entirely up to you. If you plan to use priority levels extensively in your simulation model, you might want to consider tracking and managing your priority levels. Consider writing down the levels and their meanings in your model's documentation for reference.
If you are creating tasks using the standard logic on a 3D object, look for properties that assign priority and/or preemption values in the same area where you created the task:
You can't add priority levels or preemption values to individual process flow task activities, which means you have to use other methods to re-create priority logic. Generally, the best method is to use a combination of labels, lists, and other conditional logic such as Decide activities.
For example, imagine you were modeling a system in which task executers needed to transport rush order items before transporting other items. To create this kind of system, you could:
Try completing Task Logic Tutorial 1.3 for a hands-on example of this system.
If you have a model that uses both standard logic and process flow to assign tasks to task executers, you'll need to use priority and preemption strategies that are compatible with both systems. You can only add priority and preemption to tasks in process flow using a Create Task Sequence activity, so you'll need to build task sequences in a process flow and then push those task sequences to a global list of tasks. See Using Process Flow With 3D Task Logic for a more in-depth discussion of the key concepts and strategies for combining these two methods.
Preemption determines whether a task executer will be interrupted away from its active task to work on a preempting task. It also determines what will happen to the active task when an operator is preempted away from it.
For example, the interrupted task could simply be re-added at the end of the task executer's task list. The task executer would then work on the interrupted task when it finished the preempting task. Alternatively, the active task could be entirely aborted so that it will never be worked on by the task executer.
The following table explains the different available preemption options:
Value | Name | Description |
---|---|---|
0 | No preempt | The task will not preempt a task executer. |
1 | Preempt only | The task executer will preempt the currently active task sequence and put it back in its task sequence queue to be finished later. When a task sequence is preempted, it is automatically placed at the front of the task sequence queue. When the TaskExecuter eventually comes back to the original task sequence, the current task in that task sequence will be done over again, since it was not finished. |
2 | Preempt and abort active | The task executer will stop the currently active task sequence and destroy it, so that it will never come back to that original task. |
3 | Preempt and abort all | The task executer will stop the currently active task sequence, destroy it, and destroy all tasks in its task sequence queue. |
It's possible that a task executer could be working on a preempting task at the same time it receives another preempting task. When that happens, the task logic will use the following rules: