-
Notifications
You must be signed in to change notification settings - Fork 8
Potential race condition in CommandTask #129
Comments
@rfairley and I discussed yesterday, and we figure that the issue would be solved if the CommandTask thread blocks on a binary semaphore initialized with a count of 0 instead of a signal. Case 1: CommandTask thread blocks before a context switch
Case 2: CommandTask thread is interrupted by a context switch before it can block
|
One option for implementing the semaphore is FreeRTOS's xTaskNotifyGive() macro for when using task notifications as binary semaphores. It has to be used with ulTaskNotifyTake(), which either returns immediately if the task notification value is nonzero or waits for the value to be nonzero. If in Case 2 where CommandTask got interrupted before blocking, RxThread would set the notification value to nonzero, so when CommandTask "takes" the notification, it'd see it is nonzero, and continue as it should (where previously it would have missed the notification if with With CMSIS the option is |
Did some digging into this. I first looked at CMSIS again, because The CMSIS-RTOS documentation (for version 1.02 which is the version given in our The underlying function that cmsis_os.c uses for It looks like we needn't have worried about As a side note, with regard to the binary semaphore-style |
Closing this - our use of the CMSIS API does what we want it to. |
Describe the bug
At the end of the initialization sequence in the CommandTask thread, we signal the other threads in the system (which are all a higher priority than CommandTask). We then block on a signal from the RX Task. The issue is if, a context switch to a higher-priority thread happens before we can block on this signal, we will miss it when it is set.
To Reproduce
N/A as we are currently getting lucky with our timing. This was identified after #126 was pulled in.
The text was updated successfully, but these errors were encountered: