forked from espressif/esp-idf
refactor(freertos/idf): Move xTaskIncrementTickOtherCores() to IDF additition headers
This commit moves xTaskIncrementTickOtherCores() to freertos_tasks_c_additions.h and freertos_idf_additions_priv.h (as API is private). This reduces the code differences cmpared to upstream FreeRTOS.
This commit is contained in:
@@ -3485,20 +3485,6 @@ BaseType_t xTaskGetAffinity( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
|
|||||||
*/
|
*/
|
||||||
BaseType_t xTaskIncrementTick( void ) PRIVILEGED_FUNCTION;
|
BaseType_t xTaskIncrementTick( void ) PRIVILEGED_FUNCTION;
|
||||||
|
|
||||||
#if ( configNUM_CORES > 1 )
|
|
||||||
|
|
||||||
/*
|
|
||||||
* THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS ONLY
|
|
||||||
* INTENDED FOR USE WHEN IMPLEMENTING A PORT OF THE SCHEDULER AND IS
|
|
||||||
* AN INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
|
|
||||||
*
|
|
||||||
* Called from all other cores except core 0 when their tick interrupt
|
|
||||||
* occurs. This function will check if the current core requires time slicing,
|
|
||||||
* and also call the application tick hook.
|
|
||||||
*/
|
|
||||||
BaseType_t xTaskIncrementTickOtherCores( void ) PRIVILEGED_FUNCTION;
|
|
||||||
#endif /* configNUM_CORES > 1 */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS AN
|
* THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS AN
|
||||||
* INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
|
* INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
|
||||||
|
@@ -3369,90 +3369,6 @@ BaseType_t xTaskIncrementTick( void )
|
|||||||
|
|
||||||
return xSwitchRequired;
|
return xSwitchRequired;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ( configNUM_CORES > 1 )
|
|
||||||
BaseType_t xTaskIncrementTickOtherCores( void )
|
|
||||||
{
|
|
||||||
/* Minor optimization. This function can never switch cores mid
|
|
||||||
* execution */
|
|
||||||
BaseType_t xCoreID = xPortGetCoreID();
|
|
||||||
BaseType_t xSwitchRequired = pdFALSE;
|
|
||||||
|
|
||||||
/* This function should never be called by Core 0. */
|
|
||||||
configASSERT( xCoreID != 0 );
|
|
||||||
|
|
||||||
/* Called by the portable layer each time a tick interrupt occurs.
|
|
||||||
* Increments the tick then checks to see if the new tick value will cause any
|
|
||||||
* tasks to be unblocked. */
|
|
||||||
traceTASK_INCREMENT_TICK( xTickCount );
|
|
||||||
|
|
||||||
if( uxSchedulerSuspended[ xCoreID ] == ( UBaseType_t ) 0U )
|
|
||||||
{
|
|
||||||
/* We need take the kernel lock here as we are about to access
|
|
||||||
* kernel data structures. */
|
|
||||||
taskENTER_CRITICAL_ISR( &xKernelLock );
|
|
||||||
|
|
||||||
/* A task being unblocked cannot cause an immediate context switch
|
|
||||||
* if preemption is turned off. */
|
|
||||||
#if ( configUSE_PREEMPTION == 1 )
|
|
||||||
{
|
|
||||||
/* Check if core 0 calling xTaskIncrementTick() has
|
|
||||||
* unblocked a task that can be run. */
|
|
||||||
if( uxTopReadyPriority > pxCurrentTCB[ xCoreID ]->uxPriority )
|
|
||||||
{
|
|
||||||
xSwitchRequired = pdTRUE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mtCOVERAGE_TEST_MARKER();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif /* if ( configUSE_PREEMPTION == 1 ) */
|
|
||||||
|
|
||||||
/* Tasks of equal priority to the currently running task will share
|
|
||||||
* processing time (time slice) if preemption is on, and the application
|
|
||||||
* writer has not explicitly turned time slicing off. */
|
|
||||||
#if ( ( configUSE_PREEMPTION == 1 ) && ( configUSE_TIME_SLICING == 1 ) )
|
|
||||||
{
|
|
||||||
if( listCURRENT_LIST_LENGTH( &( pxReadyTasksLists[ pxCurrentTCB[ xCoreID ]->uxPriority ] ) ) > ( UBaseType_t ) 1 )
|
|
||||||
{
|
|
||||||
xSwitchRequired = pdTRUE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mtCOVERAGE_TEST_MARKER();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif /* ( ( configUSE_PREEMPTION == 1 ) && ( configUSE_TIME_SLICING == 1 ) ) */
|
|
||||||
|
|
||||||
/* Release the previously taken kernel lock as we have finished
|
|
||||||
* accessing the kernel data structures. */
|
|
||||||
taskEXIT_CRITICAL_ISR( &xKernelLock );
|
|
||||||
|
|
||||||
#if ( configUSE_PREEMPTION == 1 )
|
|
||||||
{
|
|
||||||
if( xYieldPending[ xCoreID ] != pdFALSE )
|
|
||||||
{
|
|
||||||
xSwitchRequired = pdTRUE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mtCOVERAGE_TEST_MARKER();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif /* configUSE_PREEMPTION */
|
|
||||||
}
|
|
||||||
|
|
||||||
#if ( configUSE_TICK_HOOK == 1 )
|
|
||||||
{
|
|
||||||
vApplicationTickHook();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return xSwitchRequired;
|
|
||||||
}
|
|
||||||
#endif /* ( configNUM_CORES > 1 ) */
|
|
||||||
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
#if ( configUSE_APPLICATION_TASK_TAG == 1 )
|
#if ( configUSE_APPLICATION_TASK_TAG == 1 )
|
||||||
|
@@ -75,6 +75,92 @@ _Static_assert( offsetof( StaticTask_t, pxDummy8 ) == offsetof( TCB_t, pxEndOfSt
|
|||||||
#endif /* ( CONFIG_FREERTOS_SMP && ( configNUM_CORES > 1 ) ) */
|
#endif /* ( CONFIG_FREERTOS_SMP && ( configNUM_CORES > 1 ) ) */
|
||||||
/*----------------------------------------------------------*/
|
/*----------------------------------------------------------*/
|
||||||
|
|
||||||
|
#if ( !CONFIG_FREERTOS_SMP && ( configNUM_CORES > 1 ) )
|
||||||
|
|
||||||
|
BaseType_t xTaskIncrementTickOtherCores( void )
|
||||||
|
{
|
||||||
|
/* Minor optimization. This function can never switch cores mid
|
||||||
|
* execution */
|
||||||
|
BaseType_t xCoreID = xPortGetCoreID();
|
||||||
|
BaseType_t xSwitchRequired = pdFALSE;
|
||||||
|
|
||||||
|
/* This function should never be called by Core 0. */
|
||||||
|
configASSERT( xCoreID != 0 );
|
||||||
|
|
||||||
|
/* Called by the portable layer each time a tick interrupt occurs.
|
||||||
|
* Increments the tick then checks to see if the new tick value will
|
||||||
|
* cause any tasks to be unblocked. */
|
||||||
|
traceTASK_INCREMENT_TICK( xTickCount );
|
||||||
|
|
||||||
|
if( uxSchedulerSuspended[ xCoreID ] == ( UBaseType_t ) 0U )
|
||||||
|
{
|
||||||
|
/* We need take the kernel lock here as we are about to access
|
||||||
|
* kernel data structures. */
|
||||||
|
taskENTER_CRITICAL_ISR( &xKernelLock );
|
||||||
|
|
||||||
|
/* A task being unblocked cannot cause an immediate context switch
|
||||||
|
* if preemption is turned off. */
|
||||||
|
#if ( configUSE_PREEMPTION == 1 )
|
||||||
|
{
|
||||||
|
/* Check if core 0 calling xTaskIncrementTick() has
|
||||||
|
* unblocked a task that can be run. */
|
||||||
|
if( uxTopReadyPriority > pxCurrentTCB[ xCoreID ]->uxPriority )
|
||||||
|
{
|
||||||
|
xSwitchRequired = pdTRUE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mtCOVERAGE_TEST_MARKER();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif /* if ( configUSE_PREEMPTION == 1 ) */
|
||||||
|
|
||||||
|
/* Tasks of equal priority to the currently running task will share
|
||||||
|
* processing time (time slice) if preemption is on, and the application
|
||||||
|
* writer has not explicitly turned time slicing off. */
|
||||||
|
#if ( ( configUSE_PREEMPTION == 1 ) && ( configUSE_TIME_SLICING == 1 ) )
|
||||||
|
{
|
||||||
|
if( listCURRENT_LIST_LENGTH( &( pxReadyTasksLists[ pxCurrentTCB[ xCoreID ]->uxPriority ] ) ) > ( UBaseType_t ) 1 )
|
||||||
|
{
|
||||||
|
xSwitchRequired = pdTRUE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mtCOVERAGE_TEST_MARKER();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif /* ( ( configUSE_PREEMPTION == 1 ) && ( configUSE_TIME_SLICING == 1 ) ) */
|
||||||
|
|
||||||
|
/* Release the previously taken kernel lock as we have finished
|
||||||
|
* accessing the kernel data structures. */
|
||||||
|
taskEXIT_CRITICAL_ISR( &xKernelLock );
|
||||||
|
|
||||||
|
#if ( configUSE_PREEMPTION == 1 )
|
||||||
|
{
|
||||||
|
if( xYieldPending[ xCoreID ] != pdFALSE )
|
||||||
|
{
|
||||||
|
xSwitchRequired = pdTRUE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mtCOVERAGE_TEST_MARKER();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif /* configUSE_PREEMPTION */
|
||||||
|
}
|
||||||
|
|
||||||
|
#if ( configUSE_TICK_HOOK == 1 )
|
||||||
|
{
|
||||||
|
vApplicationTickHook();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return xSwitchRequired;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* ( !CONFIG_FREERTOS_SMP && ( configNUM_CORES > 1 ) ) */
|
||||||
|
/*----------------------------------------------------------*/
|
||||||
|
|
||||||
/* -------------------------------------------------- Task Creation ------------------------------------------------- */
|
/* -------------------------------------------------- Task Creation ------------------------------------------------- */
|
||||||
|
|
||||||
#if CONFIG_FREERTOS_SMP
|
#if CONFIG_FREERTOS_SMP
|
||||||
|
@@ -109,6 +109,22 @@
|
|||||||
|
|
||||||
#endif /* ( CONFIG_FREERTOS_SMP && ( configNUM_CORES > 1 ) ) */
|
#endif /* ( CONFIG_FREERTOS_SMP && ( configNUM_CORES > 1 ) ) */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* In ESP-IDF FreeRTOS (i.e., multi-core SMP), core 0 manages the the FreeRTOS
|
||||||
|
* tick count. Thus only core 0 calls xTaskIncrementTick().
|
||||||
|
*
|
||||||
|
* However, all other cores also receive a periodic tick interrupt. Thus all
|
||||||
|
* other cores should call this function instead.
|
||||||
|
*
|
||||||
|
* This function will check if the current core requires time slicing, and also
|
||||||
|
* call the application tick hook. However, the tick count will remain unchanged.
|
||||||
|
*/
|
||||||
|
#if ( !CONFIG_FREERTOS_SMP && ( configNUM_CORES > 1 ) )
|
||||||
|
|
||||||
|
BaseType_t xTaskIncrementTickOtherCores( void );
|
||||||
|
|
||||||
|
#endif /* ( !CONFIG_FREERTOS_SMP && ( configNUM_CORES > 1 ) ) */
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
* TASK UTILITIES (PRIVATE)
|
* TASK UTILITIES (PRIVATE)
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
|
@@ -9,6 +9,10 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "FreeRTOS.h"
|
#include "FreeRTOS.h"
|
||||||
#include "task.h"
|
#include "task.h"
|
||||||
|
#if ( !CONFIG_FREERTOS_SMP && ( configNUM_CORES > 1 ) )
|
||||||
|
/* Required for xTaskIncrementTickOtherCores() */
|
||||||
|
#include "esp_private/freertos_idf_additions_priv.h"
|
||||||
|
#endif /* ( !CONFIG_FREERTOS_SMP && ( configNUM_CORES > 1 ) ) */
|
||||||
|
|
||||||
#if CONFIG_FREERTOS_SYSTICK_USES_CCOUNT
|
#if CONFIG_FREERTOS_SYSTICK_USES_CCOUNT
|
||||||
#if CONFIG_FREERTOS_CORETIMER_0
|
#if CONFIG_FREERTOS_CORETIMER_0
|
||||||
|
Reference in New Issue
Block a user