SA0006: Write access from several tasksPermalink

Detects variables that are written by more than one task

Justification: A variable that is written in multiple tasks may change its value unexpectedly. This can lead to confusing situations. String variables (and on some 32-bit systems also 64-bit integer variables) can even reach an inconsistent state if the variable is written to two tasks simultaneously.

Exception: In specific cases, it may be necessary for several tasks to write a variable. For example, use semaphores to make sure that access does not lead to an inconsistent state.

Importance: High

PLCopen rule: CP10

Example

VAR_GLOBAL
	g_iTemp1: INT;
END_VAR

PROGRAM PLC_PRG    // Controlled by MainTask
g_iTemp1 := g_iTemp1 + INT#2;

PROGRAM PLC_PRG_1  //Controlled by SubTask
g_iTemp1 := g_iTemp1 - INT#3;


--> SA0006: Concurrent write access to 'g_iTemp1' in Tasks MainTask, SubTask