freertos: Fix xTaskIncrementTick for unwind the Tick for CPU1

xTaskIncrementTick have to unwind uxPendedTicks on CPU1 and CPU0.

Use case: If an erase operation was run on the CPU1 then it leads
to starving other tasks which waiting time. Waited tasks just skipped.

Closes: https://github.com/espressif/esp-idf/issues/1952

Closes: IDF-183
This commit is contained in:
Konstantin Kondrashov 2019-04-25 13:03:01 +08:00 committed by bot
parent 1ffaf8aad9
commit 0be4deeb22

View file

@ -2464,12 +2464,11 @@ BaseType_t xSwitchRequired = pdFALSE;
Increments the tick then checks to see if the new tick value will cause any Increments the tick then checks to see if the new tick value will cause any
tasks to be unblocked. */ tasks to be unblocked. */
/* Only let core 0 increase the tick count, to keep accurate track of time. */ /* Only allow core 0 increase the tick count in the case of xPortSysTickHandler processing. */
/* ToDo: This doesn't really play nice with the logic below: it means when core 1 is /* And allow core 0 and core 1 to unwind uxPendedTicks during xTaskResumeAll. */
running a low-priority task, it will keep running it until there is a context
switch, even when this routine (running on core 0) unblocks a bunch of high-priority if ( xPortInIsrContext() )
tasks... this is less than optimal -- JD. */ {
if ( xPortGetCoreID()!=0 ) {
#if ( configUSE_TICK_HOOK == 1 ) #if ( configUSE_TICK_HOOK == 1 )
vApplicationTickHook(); vApplicationTickHook();
#endif /* configUSE_TICK_HOOK */ #endif /* configUSE_TICK_HOOK */
@ -2477,11 +2476,10 @@ BaseType_t xSwitchRequired = pdFALSE;
esp_vApplicationTickHook(); esp_vApplicationTickHook();
#endif /* CONFIG_FREERTOS_LEGACY_HOOKS */ #endif /* CONFIG_FREERTOS_LEGACY_HOOKS */
/* if (xPortGetCoreID() == 1 )
We can't really calculate what we need, that's done on core 0... just assume we need a switch. {
ToDo: Make this more intelligent? -- JD return pdTRUE;
*/ }
return pdTRUE;
} }
@ -2606,39 +2604,11 @@ BaseType_t xSwitchRequired = pdFALSE;
} }
#endif /* ( ( configUSE_PREEMPTION == 1 ) && ( configUSE_TIME_SLICING == 1 ) ) */ #endif /* ( ( configUSE_PREEMPTION == 1 ) && ( configUSE_TIME_SLICING == 1 ) ) */
{
/* Guard against the tick hook being called when the pended tick
count is being unwound (when the scheduler is being unlocked). */
if( uxPendedTicks == ( UBaseType_t ) 0U )
{
#if ( configUSE_TICK_HOOK == 1 )
vApplicationTickHook();
#endif /* configUSE_TICK_HOOK */
#if ( CONFIG_FREERTOS_LEGACY_HOOKS == 1 )
esp_vApplicationTickHook();
#endif /* CONFIG_FREERTOS_LEGACY_HOOKS */
}
else
{
mtCOVERAGE_TEST_MARKER();
}
}
taskEXIT_CRITICAL_ISR(&xTaskQueueMutex); taskEXIT_CRITICAL_ISR(&xTaskQueueMutex);
} }
else else
{ {
++uxPendedTicks; ++uxPendedTicks;
/* The tick hook gets called at regular intervals, even if the
scheduler is locked. */
#if ( configUSE_TICK_HOOK == 1 )
{
vApplicationTickHook();
}
#endif
#if ( CONFIG_FREERTOS_LEGACY_HOOKS == 1 )
esp_vApplicationTickHook();
#endif /* CONFIG_FREERTOS_LEGACY_HOOKS */
} }
#if ( configUSE_PREEMPTION == 1 ) #if ( configUSE_PREEMPTION == 1 )