-detect-atomic-data-race
Enable detecting data race with atomic operation
Syntax
-detect-atomic-data-race
Description
-detect-atomic-data-race
specifies that the analysis must check
for data races in atomic operations.
By default, Polyspace does not check for data races in atomic operations. Bug Finder considers an operation as atomic if it can be performed in one machine instruction. For instance:
The operation:
can be performed in one machine instruction on targets where the size ofint var = 0;
int
is less than the word size or the pointer size on the target.The operation:
takes more than one cycle to be performed and is nonatomic.MYREG = (u32dma0_chbit << 8UL) | u32dma0_chbit;
See Define Atomic Operations in Multitasking Code. If you do not want to use this definition of atomic
operations and want to check every operation for data races, specify the option
-detect-atomic-data-race
.
If you run verification from the user interface (desktop products only), specify the
option in the Other field. See Other
.
Examples
In the code example, the write operation var=1;
in task
task1
executes concurrently with the read operation
local_var=var;
in task task2
. By default,
Polyspace® assumes that the write operation is atomic. Based on your environment, you
might want to extend the data race
checker to include the write
operation.
To check the atomic operations in this example for data races, at the command line, specify these options:
polyspace-bug-finder -sources SRC -checkers DATA_RACE -entry-points task1,task2,task3 -critical-section-begin begin_critical_section:cs1 -critical-section-end end_critical_section:cs1 -detect-atomic-data-race
Option | Specification | |
---|---|---|
Other | -detect-atomic-data-race | |
Configure multitasking manually | ||
Tasks (-entry-points) |
| |
Critical section details (-critical-section-begin -critical-section-end) | Starting routine | Ending routine |
begin_critical_section | end_critical_section |
Dependencies
To detect data races, you have to configure the concurrency options:
See Multitasking. If you specify the option
-detect-atomic-data-race
without configuring the concurrency options, Polyspace emits a warning.This option extends the following checkers and is not useful unless you enable at least one of the checkers:
Tips
This option is not useful in a Polyspace as You Code analysis.