AnsweredAssumed Answered

Task Synchronization

Question asked by huang Nanjing on Apr 28, 2016
Latest reply on Apr 28, 2016 by Mike Stanley

In mqx_tasks.c, the global data structures such as "struct AccelSensor thisAccel and MagSensor thisMag" are shared resources between the high priority Sampling Task and the low priority Fusion Task, I do not see any synchronization object being used in the source code to protect those shared resources.  Is there a possibility for a race condition in the sensor fusion library?

Example:

 

Sampling Task updates fGsAvg[i]

thisAccel.fGsAvg[i] = (float)thisAccel.iGsAvg[i] * thisAccel.fgPerCount;

 

Fusion Task accesses pthisAccel->fGsAvg

eCompassNED(pthisSV->fR, &(pthisSV->fDelta), pthisMag->fBcAvg, pthisAccel->fGsAvg);

 

case NED:
feCompassNED(pthisSV->fR, &(pthisSV->fDelta), pthisMag->fBcAvg, pthisAccel->fGsAvg);
break;
case ANDROID:
feCompassAndroid(pthisSV->fR, &(pthisSV->fDelta), pthisMag->fBcAvg, pthisAccel->fGsAvg);
break;
case WIN8:
default:
feCompassWin8(pthisSV->fR, &(pthisSV->fDelta), pthisMag->fBcAvg, pthisAccel->fGsAvg);

 

Thank you

Outcomes