beautypg.com

Rockwell Automation 47C626 AutoMax Programming Executive V4.2 User Manual

Page 226

background image

CĆ2

Synchronizing Tasks

The implications of scan time and priority are particularly important in applications

that require tasks to share data or to be synchronized based on hardware or

software events. Priority, however, cannot be used to synchronize tasks on

different Processors. This is because each Processor controls only the scheduling

of the tasks that reside on it. Therefore, the concept of task priority is relevant only

for the Processor on which the tasks reside. Task synchronization between

AutoMax Processors and UDC modules is handled by interrupts. See the DPS

Configuration and Programming instruction manual for more information about

UDC tasks.
In addition to priority, there are other methods of synchronizing tasks that work

with both tasks on the same Processor and tasks on different Processors. In

BASIC tasks, statements such as DELAY, WAIT, SET, OPEN, and INPUT can be

used for this purpose. In Control Block tasks, the EVENT parameter in the

(required) SCAN_LOOP statement is used to synchronize tasks. PC/Ladder Logic

tasks use the EVENT coil for task synchronization.

Examples of Task Execution

The scan time required for the highest priority task on the AutoMax Processor

should be used as a guide to determine how tasks should be scheduled. It is also

necessary to factor in system overhead, e.g., communication with the personal

computer, when assigning priority and scan time. Total Processor utilization

should be kept to 80Ć85%. Processor utilization can be monitored using the

Info/Log option in the Executive software.
See the figure below for an example of task execution. Assume you have a

priority 4 PC/Ladder task that needs to be executed approximately every 12 ticks

and that takes 4 ticks to execute. Assume you also have a less critical priority 5

BASIC task that needs to be executed approximately every 17 ticks and takes 2

ticks to execute. The PC/Ladder task would start at time 0, then finish execution at

4 ticks. At this point the BASIC task would be eligible to run (its time 0).

ЗЗЗЗ

ЗЗЗЗ

ЗЗЗЗ

ЗЗЗ

ЗЗЗ

ЗЗЗ

ЗЗ

ЗЗ

ЗЗ

0

4

6

12

16

21 23 24 26

ЗЗ

Priority 4 task

Priority 5 task

Time

If there are any scheduling conflicts between tasks, i.e., more than one task is

ready to run, priority takes precedence over scan time. A higher priority task that

is scheduled to run can suspend a lower priority task, regardless of whether the

lower priority task is ready to begin execution or has already begun executing.

The suspended task is allowed to execute or continue execution from where it

was suspended only after the higher priority task is finished.
Consider the following example. There are two tasks on a Processor: a priority 4

Control Block task that needs to be executed every 5 ticks and a priority 7 BASIC

task that needs to be executed every 8 ticks. Assume the Control Block task

requires 2 ticks to execute and the BASIC task requires 3 ticks to execute.