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 task sequences have a priority value of 0 unless you assign a different priority level to them. Task sequecnes with larger priority numbers will be completed before task sequences with a lower priority number. For example, a task sequence with a priority of 10 will be completed before a task sequence 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. Instead you can use a Create Task Sequence activity to define a priority on a task sequence that you create. Alternately, you can handle prioritization within process flow, using lists, resources, etc. and only generate task sequences after job/resource selection has been accomplished.
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 add priority and preemption to task sequences in process flow using a Create Task Sequence activity. Then, you can push the task sequence to a task sequence list. See Using Lists for Task Logic for an example of doing this. Alternately, you can dispatch the task sequence directly to a task executer or dispatcher, and allow the standard task sequence queue logic to be used.
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:
|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: