The assignment of task and CPU core is displayed in the Task Configuration object on the Tab: Task Groups tab.
More and more of today's controllers have processors with multiple CPU cores.
If CODESYS is executed on a multicore controller without using the multicore feature, then the distribution of tasks is handled by the scheduler of the operating system. This is true provided that an application is executed with multiple tasks. In this case, you have no direct influence over the distribution of tasks. Depending on the load balancing, the tasks can also run on different CPU cores.
With the CODESYS Multicore feature, the IEC tasks themselves can be assigned to dedicated CPU cores, taking the acquired number of CPU cores into account. This can result in improved performance. The IEC program should be split into several tasks for this purpose.
There are two basic different strategies in CODESYS for distributing IEC tasks over CPU cores:
-
IEC task which is linked and fixed to a CPU core:
The task is always executed on this specific CPU core. Multiple tasks can be linked to a CPU core by grouping. This is useful, for example, if the IEC program is not yet able to run on multiple CPU cores simultaneously.
-
The IEC task is executed on all CPU cores:
The operating system takes control of distributing one or more tasks of a group on the CPU cores.
|
Important | ||
|---|---|---|---|
|
When the IEC tasks are distributed over CPU cores, some changes result in the behavior in the IEC program, which have to be considered.
|
|
Important |
|---|---|
|
Data consistency
|
Requirement: At least two tasks are defined in your application, for example MainTask (IEC-Task) and LowTask (IEC-Task).
-
Open the Task Configuration object in the editor.
-
Switch to the Task Groups tab.
The overview shows the default IEC-Tasks task group.
-
Click Add Group to add a new task group.
The
NewGroupgroup is added. -
Double-click the group name
NewGroupand change it toLowGroup. -
In Core, select an assignment (example 1).
-
Open the task
LowTask(IEC-Task) in the editor. -
In Task Group, select the new group
LowGroup.The
LowTasktask is processed now by processor core 1 due to its group membership inLowGroup.