Why do I get an unjustified error message with critical sections ?

1 view (last 30 days)
We explain why Polyspace gives a wrong error message about a limitation with critical sections.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 25 Feb 2011
There is a documented limitation with critical sections when the beginning and end of a critical section are not in the same block. The message will occur on the C to Il phase and will look like:
...
** C to intermediate language translation - 12 (P_G)
----------------------------------------------------------------------
Limitation: Beginning then end of critical section must be in same block : file.function
|This construction is not supported by PolySpace Verifier.
|The computation has been halted.
But this limitation is raised if the parameters of the functions defining the beginning and end of the critical section are pointers to an object.
Ex:
MyType variable;
CriticalRegion_Enter(&variable);
// some code
CriticalRegion_Exit(&variable);
The workaround is to use a temporary variable as the argument:
MyType variable;
MyType * p_variable;
p_variable = &variable;
CriticalRegion_Enter(p_variable);
// some code
CriticalRegion_Exit(p_variable);

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!