Tasks

A task is a runtime object that can be scheduled and triggered by a scheduler. Functions or runtime objects that are to be executed in the context of this object log on to this object. The tasks are assigned a cycle time and a priority, which the scheduler uses to schedule the execution of the tasks (see Real-time scheduling). Furthermore, each task is assigned a shared memory/address space, which all tasks can access together, and an additional stack memory. This stack memory is required to allow the nested execution of functions and sub-functions. The stack also serves as a memory for local variables. The state of a task is defined by this stack and the current content of the machine registers (calculation registers). If there is a context change or a task is interrupted by a higher priority, this state is saved and restored when the task is executed again. The size of the task stack can be defined in TwinCAT (see chapter Settings tab of the real-time settings).

For sequence control of several tasks, a (real-time) system offers functions for communication and synchronization (see chapter Multi-task data access synchronization in the PLC).

The corresponding task types are described in the following chapters.