Hi All,
I have a global struct added to my task using taskVarAdd() API.
But during some scenarios, the same global struct is is added to the same task again using taskVarAdd() API. [i.e., taskVarAdd() is called twice from a task for a same variable].
This struct will maintain the taskID, message queue ids for that task
Following is the sample program witten by Benoit to explain the scenario,
int v1;
void tvl()
{
int i = 0;
v1 = 1;
taskVarAdd(0, &v1);
v1 = 2;
taskVarAdd(0, &v1);
v1 = 3;
taskDelay(1);
printf("Initial v1 = %d\n", v1);
for(i = 0;i<10;i++)
{
v1++;
taskDelay(60);
printf("v1 = %d\n", v1);
}
}
When I tested the code using tornado and i am getting different results every time i execute your program
//1st Attempt -> tv1
Inital v1 = V1 = 3
V1 = 3
V1 = 2
V1 = 4
V1 = 4
V1 = 3
V1 = 5
V1 = 5
V1 = 5
V1 = 6
//2nd attempt
-> tv1
Inital v1 = V1 = 1
V1 = 3
V1 = 4
V1 = 2
V1 = 4
V1 = 5
V1 = 3
V1 = 5
V1 = 6
But When i commented the second taskVarAdd() and tested it, i am getting the consistent expected results as follows
//1st Attempt
-> tv1
Inital v1 = 3
V1 = 4
V1 = 5
V1 = 6
V1 = 7
V1 = 8
V1 = 9
V1 = 10
V1 = 11
V1 = 12
V1 = 13
//2nd Attempt
-> tv1
Inital v1 = 3
V1 = 4
V1 = 5
V1 = 6
V1 = 7
V1 = 8
V1 = 9
V1 = 10
V1 = 11
V1 = 12
V1 = 13
We are using VxWork 5.5
My Questions:
Is it right to use two taskVarAdd() inside same task for same variable?
What will be the behavior if two taskVarAdd() is used for same variable inside same task?
Kindly explain the flow of your program