Closed chinglee-iot closed 3 months ago
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 92.31%. Comparing base (
8c49c54
) to head (62940d3
). Report is 46 commits behind head on main.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Excuse me, I am confused with this patch.
Upon the next scheduling of the task, the assertion configASSERT(pxThisTCB->xTaskRunState != taskTASK_SCHEDULED_TO_YIELD); may not be true, as other cores could have requested a yield for this task before it evaluates its run state within the assertion.
Why not it may be true, if other cores request a yield, it will send a irq to this core firstly and change its task run state.
#define prvYieldCore( xCoreID ) \ else \ { \ /* Request other core to yield if it is not requested before. */ \ if( pxCurrentTCBs[ ( xCoreID ) ]->xTaskRunState != taskTASK_SCHEDULED_TO_YIELD ) \ { \ portYIELD_CORE( xCoreID ); \ pxCurrentTCBs[ ( xCoreID ) ]->xTaskRunState = taskTASK_SCHEDULED_TO_YIELD; \ } \ } \ } while( 0 )
Does it mean that the irq is not be responded if run state is taskTASK_SCHEDULED_TO_YIELD?
@Saiiijchan I think the assumption for this configASSERT is that the core which is requested to yield will yield immediately without any latency. However, on some platforms, the core can still execute some instructions before it jumps to the interrupt handler for the yield request. The proper way to check the run state should be performed in a critical section and in a loop.
Description
Address the problem in this thread.
https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/76eb44382178237197a2c4982f9d99e8d64c9599/tasks.c#L846-L853 In
prvCheckForRunStateChange()
, enabling interrupts should cause this core to immediately service the pending interrupt and yield. Upon the next scheduling of the task, the assertionconfigASSERT(pxThisTCB->xTaskRunState != taskTASK_SCHEDULED_TO_YIELD);
may not be true, as other cores could have requested a yield for this task before it evaluates its run state within the assertion. To address this, the task re-evaluates its run state in critical section within a loop until it is eligible for execution, which is the current implementation. Consequently, this assertion should be removed to ensure correct behavior.In this PR:
prvCheckForRunStateChange()
as it doesn't account for the possibility that the task run state could be modified by another task after interrupt is enabled and checking the run state of a task should be performed in a critical section.Test Steps
Forum user helps to test this on a Cortex A53 SMP port, with this PR. The main_full demo can run for 5 hours without problem.
Checklist:
Related Issue
Forum thread.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.