Detects whether or not non-atomic variables (for example, with data type STRING
, WSTRING
, ARRAY
, STRUCT
, FB instances, 64-bit data types) are used in more than one task
Justification: When there is no synchronization during access, inconsistent values can be read when reading in one task and writing in another task at the same time.
Importance: Medium
For some data types, especially 64-bit integers, it depends on the platform whether or not access is atomic. Static analysis reports a problem only when the controller does not support atomic access to 64-bit integer data types.
This rule does not apply in the following cases:
-
If the target system has a floating point unit (FPU), then access of multiple tasks to
LREAL
variables is not detected -
If the target system is a 64-bit processor or the corresponding target setting is set for the target device, then the rule does not apply to 64-bit data types
Example
The project contains both programs, PRG1
and PRG2
: The program PRG1
is called by the task MainTask_1
. The program PRG2
is called by the task MainTask_2
.
GVL VAR_GLOBAL lrTest : LREAL; // Since the target system has an FPU, SA0103 does apply. lint1 : LINT; sTest : STRING; // SA0103 wsTest : WSTRING; // SA0103 END_VAR PROGRAM PRG1 GVL.lrTest := 5.0; GVL.sTest := 'welt'; GVL.wsTest := "welt"; GVL.lint1 := 99; PROGRAM PRG2 GVL.lrTest := 5.0; GVL.sTest := 'hallo'; GVL.wsTest := "hallo"; GVL.lint1 := 88; --> SA0103: Concurrent access on not atomic data 'sTest' --> SA0103: Concurrent access on not atomic data 'wsTest'