Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
CoDeSys V 3.x
SysTask.library
CONTENT
1 OVERVIEW 4
2 LIBRARY MODULES 5
2.1 SysTaskCheckStack 5
2.2 SysTaskCreate 5
2.3 SysTaskCreate2 6
2.4 SysTaskDestroy 7
2.5 SysTaskEnd 7
2.6 SysTaskEnter 7
2.7 SysTaskExit 7
2.8 SysTaskGenerateException 8
2.9 SysTaskGetContext 8
2.10 SysTaskGetCurrent 8
2.11 SysTaskGetCurrentOSHandle 8
2.12 SysTaskGetInfo 9
2.13 SysTaskGetInterval 9
2.14 SysTaskGetOSHandle 9
2.15 SysTaskGetOSPriority 9
2.16 SysTaskGetPriority 10
2.17 SysTaskJoin 10
2.18 SysTaskLeave 10
2.19 SysTaskResume 10
2.20 SysTaskSetExit 11
2.21 SysTaskSetInterval 11
2.22 SysTaskSetPriority 11
2.23 SysTaskSuspend 11
2.24 SysTaskWaitInterval 12
2.25 SysTaskWaitSleep 12
2.26 SysTaskWaitSleepUs 12
2.27 Structure RegContext 12
2.28 Structure SYS_TASK_INFO 13
2.29 Structure SYS_TASK_PARAM 13
CHANGE HISTORY 14
libdoc_e.dot / V1.0
1 Overview
Note: It depends on the target system, which system libraries can be used in the application program.
This library serves to manage cyclic tasks. As far as the target system supports the
functionality the library functions can be used to generate or delete tasks, to set them to a
specific priority, to stop and restart them etc. Processing is synchronous.
Note: These functions are not reentrant. For normal use cases this should be irrelevant. However, if case of
multiple IEC tasks creating and managing dynamically further tasks, these calls have to be guarded against
each other within the application, e.g. by use of the library SysLibSem.
(To retrieve special information on the configuration of IEC tasks you may use the library
SysLibIECTasks23.lib.)
SysTaskGetInterval RegContext
SysTaskGetOSHandle SYS_TASK_INFO
SysTaskGetOSPriority SYS_TASK_PARAM
libdoc_e.dot / V1.0
2 Library Modules
2.1 SysTaskCheckStack
By use of this function the maximum depth of a stack can be retrieved. Actually however, this
is not yet implemented for any platform, the function always returns the error message
ERR_MOT_IMPLEMENTED.
The return of type UDINT is an error code indicating success or failure of the operation (see
document "Runtime Error Codes").
Input variable Data type Description
2.2 SysTaskCreate
This function serves to generate and immediately start a task. The parameters thereby
defined get stored as components of the structure SYS_TASK_INFO (see 2.28) and
SYS_TASK_PARAM (see 2.29). Via parameter phTaskHandle the function provides an
unique ID number (handle) of the task, which is a necessary input for other library functions.
The return of type UDINT is an error code indicating success or failure of the operation (see
document "Runtime Error Codes").
Input variable Data type Description
2.3 SysTaskCreate2
By use of this function a task is created, but not started. The parameters thereby defined get
stored as components of the structure SYS_TASK_INFO (see 2.28) and SYS_TASK_PARAM
(see 2.29). Via parameter phTaskHandle the function provides an unique ID number (handle)
of the task, which is a necessary input for other library functions.
The return of type UDINT is an error code indicating success or failure of the operation (see
document "Runtime Error Codes").
Input variable Data type Description
2.4 SysTaskDestroy
By use of this function the task identified by its handle (ID) is deleted.
The return of type UDINT is an error code indicating success or failure of the operation (see
document "Runtime Error Codes").
Input variable Data type Description
2.5 SysTaskEnd
This function has to be called by a task whose processing is being stopped. Typically, the call
should be carried out right before the task will be left to ensure a proper exit of the task and
release of the resources.
The return of type UDINT is an error code indicating success or failure of the operation (see
document "Runtime Error Codes").
Input variable Data type Description
ulExitCode UDINT Exit code, that is the message created while leaving
the task (operating system specific)
2.6 SysTaskEnter
By use of this function a task is set to state active. See SysTaskLeave (2.18) for marking a
regular end of processing.
The return of type UDINT is an error code indicating success or failure of the operation (see
document "Runtime Error Codes").
Input variable Data type Description
2.7 SysTaskExit
This functions tries to terminate a task regularly. If the task does not respond during a defined
timeout, the task will be deleted by force, whereby the resources of the operating system will
not be released.
The return of type UDINT is an error code indicating success or failure of the operation (see
document "Runtime Error Codes").
Input variable Data type Description
ulTimeoutMS UDINT Time span (in milliseconds), wherein the task will be
terminated regularly. Afterwards it will be deleted by
force.
2.8 SysTaskGenerateException
This function calls the exception handler that is associated to the task specified by its handle
(SYS_TASK_INFO.pExceptionHandler^, 2.28). If there is no exception handler specified, the
standard exception routine will be called.
The return of type UDINT is an error code indicating success or failure of the operation (see
document "Runtime Error Codes").
Input variable Data type Description
2.9 SysTaskGetContext
This functions retrieves the actual context (register content) of the task. Thereto, the task has
to be suspended (by use of SysTaskSuspend (2.23) or by the operating system itself).
The return of type UDINT is an error code indicating success or failure of the operation (see
document "Runtime Error Codes").
Input variable Data type Description
2.10 SysTaskGetCurrent
This function retrieves the ID (handle) of the task currently processed. See also
SysTaskGetCurrentOSHandle and SysTaskGetOSHandle.
The return of type UDINT is an error code indicating success or failure of the operation (see
document "Runtime Error Codes").
Input variable Data type Description
2.11 SysTaskGetCurrentOSHandle
This function retrieves the operating system specific ID (handle) of the task currently
processed. See also SysTaskGetOSHandle und SysTaskGetCurrent.
The return of type UDINT is an error code indicating success or failure of the operation (see
libdoc_e.dot / V1.0
2.12 SysTaskGetInfo
By use of this function you may request information on the task specified by its handle, which
has been stored in a variable of type SYS_TASK_INFO.
The return of type UDINT is an error code indicating success or failure of the operation (see
document "Runtime Error Codes").
Input variable Data type Description
2.13 SysTaskGetInterval
This function retrieves the actual interval of a cyclic task. If the specified task is not of cyclic
type, the function will return an error.
The return of type UDINT is an error code indicating success or failure of the operation (see
document "Runtime Error Codes").
Input variable Data type Description
2.14 SysTaskGetOSHandle
This function retrieves the operating system specific ID of the task specified by its handle. See
also SysTaskGetCurrentOSHandle and SysTaskGetCurrent.
The return of type UDINT is an error code indicating success or failure of the operation (see
document "Runtime Error Codes").
Input variable Data type Description
2.15 SysTaskGetOSPriority
This function retrieves the operating system specific priority of the task determined by its
handle. In general, this priority does not equal the IEC priority of the task specified within the
application area. See also SysTaskGetPriority and SysTaskSetPriority.
2.28).
pulOSPriority POINTER TO Pointer to variable being assigned to the operating
UDINT system specific priority of the task
2.16 SysTaskGetPriority
This function retrieves the IEC priority of the task determined by its handle. See also
SysTaskSetPriority und SysTaskGetOSPriority.
The return of type UDINT is an error code indicating success or failure of the operation (see
document "Runtime Error Codes").
Input variable Data type Description
2.17 SysTaskJoin
This function serves for awaiting the termination of a task that should be joined by another
task. The function will return NOT_IMPLEMENTED on some target systems.
The return of type UDINT is an error code indicating success or failure of the operation (see
document "Runtime Error Codes").
Input variable Data type Description
2.18 SysTaskLeave
This function serves to mark the end of processing for a task specified by its handle. That is,
this task will be set to state inactive. See also SysTaskEnter (2.6).
The return of type UDINT is an error code indicating success or failure of the operation (see
document "Runtime Error Codes").
Input variable Data type Description
2.19 SysTaskResume
This function serves to restart a task having been suspended by use of the function
SysTaskSuspend (2.23).
The return of type UDINT is an error code indicating success or failure of the operation (see
document "Runtime Error Codes").
Input variable Data type Description
libdoc_e.dot / V1.0
2.20 SysTaskSetExit
This function serves to set the exit flag of the task specified by its handle (ID). Within the next
cycle the task will get terminated by itself. See also SysTaskExit (2.7).
The return of type UDINT is an error code indicating success or failure of the operation (see
document "Runtime Error Codes").
Input variable Data type Description
hTask UDINT ID of task whose exit flag shall be set (see structure
SYS_TASK_INFO, 2.28).
2.21 SysTaskSetInterval
This function serves to set the actual interval of a cyclic task. That can be used to synchronize
one task with another or with an event. If the specified task is not of cyclic task, the function
will return an error. See also SysTaskGetInterval (2.13).
The return of type UDINT is an error code indicating success or failure of the operation (see
document "Runtime Error Codes").
Input variable Data type Description
2.22 SysTaskSetPriority
This function serves to set the IEC priority of a task. See also SysTaskGetPriority (2.16).
The return of type UDINT is an error code indicating success or failure of the operation (see
document "Runtime Error Codes").
Input variable Data type Description
2.23 SysTaskSuspend
By use of this function a task is suspended from being processed. Processing may be
continued by a call to function SysTaskResume (2.19).
libdoc_e.dot / V1.0
The return of type UDINT is an error code indicating success or failure of the operation (see
document "Runtime Error Codes").
Input variable Data type Description
2.24 SysTaskWaitInterval
Only for operating systems that support a cyclic processing of tasks! In this case you can use
the function SysTaskWaitInterval to shift the begin of processing the specified task to the start
point of the next time interval (see structure SysTaskParam, ulInterval in chapter 2.29).
The return of type UDINT is an error code indicating success or failure of the operation (see
document "Runtime Error Codes").
Input variable Data type Description
2.25 SysTaskWaitSleep
This function serves to pause the processing of a running task for a time interval specified in
milliseconds. Processing will be continued after the time interval elapsed.
The return of type UDINT is an error code indicating success or failure of the operation (see
document "Runtime Error Codes").
Input variable Data type Description
2.26 SysTaskWaitSleepUs
This function serves to pause the processing of a running task for a time interval specified in
microseconds. The function is not implemented on every platform.
The return of type UDINT is an error code indicating success or failure of the operation (see
document "Runtime Error Codes").
Input variable Data type Description
Change History
Version Description Date