
6.3 Configuration Elements 235
TASK Parameter Meaning
SINGLE On a rising edge at this input programs associated with the TASK
will be called and executed once.
INTERVAL If a time value different from zero is supplied, all programs associa-
ted with the TASK will be executed cyclically (periodically). The
value supplied is the interval between two invocations. This value
can thus be used to set and monitor cycle time. If the input value is
zero, the programs will not be called.
PRIORITY This input defines the priority of the associated programs compared
to other programs running concurrently (multitasking). The meaning
is implementation-dependent (see text).
Table 6.2. TASK properties as input parameters
The meaning of the PRIORITY input will depend on how concurrency of multiple
programs is implemented in the PLC system, and is therefore implementation-
dependent. If a task with a priority higher than that of the task currently executing
is activated, there are in principle two ways of resolving this conflict between tasks
on the same CPU. It depends on the ability of the PLC system to interrupt a
running task:
1) The task currently executing is interrupted immediately, to start execution of
the task with higher priority. This is called pre-emptive scheduling.
2) The task currently executing is
not
interrupted, but continues normally until
termination. Only then will the task with the highest priority of all
waiting
tasks
be executed. This is called non-pre-emptive scheduling.
Both methods give the task with the highest priority control of the requested re-
source. If a task with the same priority as the task currently executing is scheduled
to execute, it has to wait. If tasks with the same priority are waiting to execute, the
one which has been waiting longest will be executed first.
TASK T_Quick (INTERVAL := t#8ms, PRIORITY := 1);
PROGRAM Motion WITH T_Quick : ProgA ( RegPar := %MW3,
R_Val => ErrorCode);
TASK T_Interrupt (SINGLE := Trigger, PRIORITY := 1);
PROGRAM Lube WITH T_Interrupt : ProgC;
Example 6.3. Elements TASK and PROGRAM...WITH... from Example 6.6
In Example 6.3, two tasks
T_Quick
(cyclic with short cycle time) and
T_Interrupt
(interrupt task with high priority) are defined.