Code Prover and Bug Finder finding race condition bug problem.
Show older comments
typedef struct
{
uint8_ t var_u8;
uint16_t var_u16;
uint32_t var_u32;
}global_struct;
% Global Variables
global_struct gs;
uint32_t global_variable = 0;
void increment(uint32_t* i)
{
(*i)++;
}
void Task_1(void)
{
while(1)
{
global_variable++;
increment(&gs.var_u32);
}
}
void Task_2(void)
{
while(1)
{
global_variable++;
increment(&gs.var_u32);
}
}
In the code above we run bug finder and code prover. After completing the analysis bug finder finds only global_variable++ using task1 and task2 race condition.
Code prover finds same error as an protected variable in orange check for global_variable and also finds same error in inside of increment function. Eventhough code prover finding error it shows error on gs struct but it does not point the variable which inside of gs struct(var_u8, var_16, var_u32). That is not enough to understand for error in which variable. How can i find the exactly error inside of the struct ? Is there any sample of this kind of code ?
Note: I followed documentation for all the configuration. In multitasking, i defined my tasks, interrupts and critical sections.
Answers (1)
Anirban
on 9 Jan 2023
0 votes
You can see which structure field is accessed on the Variable Access pane.

1 Comment
Husnu umut Okur
on 13 Jan 2023
Categories
Find more on Multitasking in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!