fix: race condition on mixer task handle (#3914)

PR #3451 moved the start of the mixer task to a point in time where the task scheduler is already started (UI task). Before that change, the mixer task would be created before and effectively started after the task scheduler started.

This introduces a race condition on `mixerTaskId.rtos_handle`, as the mixer scheduler might trigger before `xTaskCreateStatic()` returns and the task handle is assigned.

This PR fixes the issue by delaying the start of the mixer scheduler until `xTaskCreateStatic()` returned and the task handler has been properly assigned.
This commit is contained in:
Raphael Coeffic
2023-08-07 13:34:38 +02:00
committed by GitHub
parent ac4aeef579
commit 017ac82d59
+2 -3
View File
@@ -60,9 +60,11 @@ void mixerTaskUnlock()
void mixerTaskInit()
{
mixerSchedulerInit();
RTOS_CREATE_MUTEX(mixerMutex);
RTOS_CREATE_TASK(mixerTaskId, mixerTask, "mixer", mixerStack,
MIXER_STACK_SIZE, MIXER_TASK_PRIO);
mixerSchedulerStart();
}
bool mixerTaskStarted()
@@ -147,9 +149,6 @@ TASK_FUNCTION(mixerTask)
gyroInit();
#endif
mixerSchedulerInit();
mixerSchedulerStart();
while (!_mixer_exit) {
int timeout = 0;