User`s guide

Task Scheduler
Execution Priority Example
The following example shows how the task priority scheme works. The example makes the
following assumptions:
l Task 0 runs in all time slices at priority 20
l Task 1 runs in all time slices at priority 10
l Task 2 runs in all time slices at priority 20
l All system tasks are ignored (systems tasks are described in the next section)
l All system interrupts are ignored
The following figure shows three tasks executing concurrently. Note that since no LOCK or
REACT_ instructions are issued, the program priority remains 0 for the entire segment. (See
"Program Interrupt Instructions" for descriptions of the REACT routines, the LOCK
instruction, and another program execution example.)
The illustration shows the timelines of executing programs. A solid line indicates a program is
running; a dotted line indicates a program is waiting. The Y axis shows the program priority.
The X axis is divided into 1-millisecond time slices.
The sequence of events for Priority Example 1 is:
(the line numbers are referenced in the following figure)
1. prog_a issues a WAIT.EVENT. This suspends prog_a and passes execution to the next
highest task which is task 2 running prog_c.
2. prog_c runs until it issues a RELEASE instruction. Since the RELEASE has no
arguments, execution is passed to the next highest task with a program to run. Since
task 0 is waiting on a SET.EVENT, the next task is task 1.
3. Task 2 issues a SET.EVENT to task 0 and runs until the end of a time slice at which
time task 0 runs. Tasks 0 and 2 have the same priority so they swap execution. (If
two tasks with equal priority are ready to run, the least recently run task runs.)
4. prog_a waits for a disk I/O operation to complete. The next highest priority task is 2
which runs until the I/O operation completes and task 0 becomes the least recently
run task.
5. prog_a completes, passing control to task 2.
6. prog_c completes, passing control to task 1.
Notice that unless both task 0 and task 2 are waiting or do not have a program to run, or
task 0 or task 2 RELEASEs to task 1, task 1 is effectively blocked from execution.
Scheduling of Program Execution Tasks
(Undefined variable: Primary.Product_Name_V)Language User's Guide, version
17.x
Page 53