Add vApplicationGetPassiveIdleTaskMemory for SMP (#890)

* Update vApplicationGetIdleTaskMemory prototype for SMP. Now SMP and
  single core use the same prototype for compatibility.
* Add vApplicationGetPassiveIdleTaskMemory for SMP to get passive idle
  task memory.
pull/893/head^2
chinglee-iot 1 year ago committed by GitHub
parent ad13a1f8df
commit dc09a3dd51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1961,8 +1961,6 @@ configSTACK_DEPTH_TYPE uxTaskGetStackHighWaterMark2( TaskHandle_t xTask ) PRIVIL
#if ( configSUPPORT_STATIC_ALLOCATION == 1 ) #if ( configSUPPORT_STATIC_ALLOCATION == 1 )
#if ( configNUMBER_OF_CORES == 1 )
/** /**
* task.h * task.h
* @code{c} * @code{c}
@ -1979,12 +1977,11 @@ configSTACK_DEPTH_TYPE uxTaskGetStackHighWaterMark2( TaskHandle_t xTask ) PRIVIL
void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer, void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer,
StackType_t ** ppxIdleTaskStackBuffer, StackType_t ** ppxIdleTaskStackBuffer,
uint32_t * pulIdleTaskStackSize ); /*lint !e526 Symbol not defined as it is an application callback. */ uint32_t * pulIdleTaskStackSize ); /*lint !e526 Symbol not defined as it is an application callback. */
#else /* #if ( configNUMBER_OF_CORES == 1 ) */
/** /**
* task.h * task.h
* @code{c} * @code{c}
* void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer, StackType_t ** ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize, BaseType_t xCoreID ) * void vApplicationGetPassiveIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer, StackType_t ** ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize, BaseType_t xCoreID )
* @endcode * @endcode
* *
* This function is used to provide a statically allocated block of memory to FreeRTOS to hold the Idle Tasks TCB. This function is required when * This function is used to provide a statically allocated block of memory to FreeRTOS to hold the Idle Tasks TCB. This function is required when
@ -1996,20 +1993,21 @@ configSTACK_DEPTH_TYPE uxTaskGetStackHighWaterMark2( TaskHandle_t xTask ) PRIVIL
* These idle tasks are created to ensure that each core has an idle task to run when * These idle tasks are created to ensure that each core has an idle task to run when
* no other task is available to run. * no other task is available to run.
* *
* The function vApplicationGetIdleTaskMemory is called with xCoreID 0 to get the * The function vApplicationGetPassiveIdleTaskMemory is called with passive idle
* memory for Active idle task. It is called with xCoreID 1, 2 ... ( configNUMBER_OF_CORES - 1 ) * task index 0, 1 ... ( configNUMBER_OF_CORES - 2 ) to get memory for passive idle
* to get memory for passive idle tasks. * tasks.
* *
* @param ppxIdleTaskTCBBuffer A handle to a statically allocated TCB buffer * @param ppxIdleTaskTCBBuffer A handle to a statically allocated TCB buffer
* @param ppxIdleTaskStackBuffer A handle to a statically allocated Stack buffer for the idle task * @param ppxIdleTaskStackBuffer A handle to a statically allocated Stack buffer for the idle task
* @param pulIdleTaskStackSize A pointer to the number of elements that will fit in the allocated stack buffer * @param pulIdleTaskStackSize A pointer to the number of elements that will fit in the allocated stack buffer
* @param xCoreId The core index of the idle task buffer * @param xPassiveIdleTaskIndex The passive idle task index of the idle task buffer
*/ */
void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer, #if ( configNUMBER_OF_CORES > 1 )
void vApplicationGetPassiveIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer,
StackType_t ** ppxIdleTaskStackBuffer, StackType_t ** ppxIdleTaskStackBuffer,
uint32_t * pulIdleTaskStackSize, /*lint !e526 Symbol not defined as it is an application callback. */ uint32_t * pulIdleTaskStackSize,
BaseType_t xCoreID ); BaseType_t xPassiveIdleTaskIndex );
#endif /* #if ( configNUMBER_OF_CORES == 1 ) */ #endif /* #if ( configNUMBER_OF_CORES > 1 ) */
#endif /* if ( configSUPPORT_STATIC_ALLOCATION == 1 ) */ #endif /* if ( configSUPPORT_STATIC_ALLOCATION == 1 ) */
/** /**

@ -3575,10 +3575,21 @@ static BaseType_t prvCreateIdleTasks( void )
/* The Idle task is created using user provided RAM - obtain the /* The Idle task is created using user provided RAM - obtain the
* address of the RAM then create the idle task. */ * address of the RAM then create the idle task. */
#if ( configNUMBER_OF_CORES == 1 ) #if ( configNUMBER_OF_CORES == 1 )
{
vApplicationGetIdleTaskMemory( &pxIdleTaskTCBBuffer, &pxIdleTaskStackBuffer, &ulIdleTaskStackSize ); vApplicationGetIdleTaskMemory( &pxIdleTaskTCBBuffer, &pxIdleTaskStackBuffer, &ulIdleTaskStackSize );
}
#else #else
vApplicationGetIdleTaskMemory( &pxIdleTaskTCBBuffer, &pxIdleTaskStackBuffer, &ulIdleTaskStackSize, xCoreID ); {
#endif if( xCoreID == 0 )
{
vApplicationGetIdleTaskMemory( &pxIdleTaskTCBBuffer, &pxIdleTaskStackBuffer, &ulIdleTaskStackSize );
}
else
{
vApplicationGetPassiveIdleTaskMemory( &pxIdleTaskTCBBuffer, &pxIdleTaskStackBuffer, &ulIdleTaskStackSize, xCoreID - 1 );
}
}
#endif /* if ( configNUMBER_OF_CORES == 1 ) */
xIdleTaskHandles[ xCoreID ] = xTaskCreateStatic( pxIdleTaskFunction, xIdleTaskHandles[ xCoreID ] = xTaskCreateStatic( pxIdleTaskFunction,
cIdleName, cIdleName,
ulIdleTaskStackSize, ulIdleTaskStackSize,
@ -8523,8 +8534,6 @@ static void prvAddCurrentTaskToDelayedList( TickType_t xTicksToWait,
* it's own implementation of vApplicationGetIdleTaskMemory by setting * it's own implementation of vApplicationGetIdleTaskMemory by setting
* configKERNEL_PROVIDED_STATIC_MEMORY to 0 or leaving it undefined. * configKERNEL_PROVIDED_STATIC_MEMORY to 0 or leaving it undefined.
*/ */
#if ( configNUMBER_OF_CORES == 1 )
void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer, void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer,
StackType_t ** ppxIdleTaskStackBuffer, StackType_t ** ppxIdleTaskStackBuffer,
uint32_t * pulIdleTaskStackSize ) uint32_t * pulIdleTaskStackSize )
@ -8537,22 +8546,22 @@ static void prvAddCurrentTaskToDelayedList( TickType_t xTicksToWait,
*pulIdleTaskStackSize = configMINIMAL_STACK_SIZE; *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;
} }
#else /* #if ( configNUMBER_OF_CORES == 1 ) */ #if ( configNUMBER_OF_CORES > 1 )
void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer, void vApplicationGetPassiveIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer,
StackType_t ** ppxIdleTaskStackBuffer, StackType_t ** ppxIdleTaskStackBuffer,
uint32_t * pulIdleTaskStackSize, uint32_t * pulIdleTaskStackSize,
BaseType_t xCoreId ) BaseType_t xPassiveIdleTaskIndex )
{ {
static StaticTask_t xIdleTaskTCBs[ configNUMBER_OF_CORES ]; static StaticTask_t xIdleTaskTCBs[ configNUMBER_OF_CORES - 1 ];
static StackType_t uxIdleTaskStacks[ configNUMBER_OF_CORES ][ configMINIMAL_STACK_SIZE ]; static StackType_t uxIdleTaskStacks[ configNUMBER_OF_CORES - 1 ][ configMINIMAL_STACK_SIZE ];
*ppxIdleTaskTCBBuffer = &( xIdleTaskTCBs[ xCoreId ] ); *ppxIdleTaskTCBBuffer = &( xIdleTaskTCBs[ xPassiveIdleTaskIndex ] );
*ppxIdleTaskStackBuffer = &( uxIdleTaskStacks[ xCoreId ][ 0 ] ); *ppxIdleTaskStackBuffer = &( uxIdleTaskStacks[ xPassiveIdleTaskIndex ][ 0 ] );
*pulIdleTaskStackSize = configMINIMAL_STACK_SIZE; *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;
} }
#endif /* #if ( configNUMBER_OF_CORES == 1 ) */ #endif /* #if ( configNUMBER_OF_CORES > 1 ) */
#endif /* #if ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configKERNEL_PROVIDED_STATIC_MEMORY == 1 ) && ( portUSING_MPU_WRAPPERS == 0 ) ) */ #endif /* #if ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configKERNEL_PROVIDED_STATIC_MEMORY == 1 ) && ( portUSING_MPU_WRAPPERS == 0 ) ) */
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/

Loading…
Cancel
Save