Skip to content

Commit

Permalink
fix: race condition on mixer task handle
Browse files Browse the repository at this point in the history
PR #3451 introduced a change that caused the mixer task to be started out of the UI task, which introduces a race condition `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.
  • Loading branch information
raphaelcoeffic committed Aug 7, 2023
1 parent 441123d commit f84c546
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions radio/src/tasks/mixer_task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -147,9 +149,6 @@ TASK_FUNCTION(mixerTask)
gyroInit();
#endif

mixerSchedulerInit();
mixerSchedulerStart();

while (!_mixer_exit) {

int timeout = 0;
Expand Down

0 comments on commit f84c546

Please sign in to comment.