Skip to content

Commit dc09a3d

Browse files
authored
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.
1 parent ad13a1f commit dc09a3d

File tree

2 files changed

+48
-41
lines changed

2 files changed

+48
-41
lines changed

include/task.h

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1961,8 +1961,6 @@ configSTACK_DEPTH_TYPE uxTaskGetStackHighWaterMark2( TaskHandle_t xTask ) PRIVIL
19611961

19621962
#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
19631963

1964-
#if ( configNUMBER_OF_CORES == 1 )
1965-
19661964
/**
19671965
* task.h
19681966
* @code{c}
@@ -1976,15 +1974,14 @@ configSTACK_DEPTH_TYPE uxTaskGetStackHighWaterMark2( TaskHandle_t xTask ) PRIVIL
19761974
* @param ppxIdleTaskStackBuffer A handle to a statically allocated Stack buffer for the idle task
19771975
* @param pulIdleTaskStackSize A pointer to the number of elements that will fit in the allocated stack buffer
19781976
*/
1979-
void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer,
1980-
StackType_t ** ppxIdleTaskStackBuffer,
1981-
uint32_t * pulIdleTaskStackSize ); /*lint !e526 Symbol not defined as it is an application callback. */
1982-
#else /* #if ( configNUMBER_OF_CORES == 1 ) */
1977+
void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer,
1978+
StackType_t ** ppxIdleTaskStackBuffer,
1979+
uint32_t * pulIdleTaskStackSize ); /*lint !e526 Symbol not defined as it is an application callback. */
19831980

19841981
/**
19851982
* task.h
19861983
* @code{c}
1987-
* void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer, StackType_t ** ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize, BaseType_t xCoreID )
1984+
* void vApplicationGetPassiveIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer, StackType_t ** ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize, BaseType_t xCoreID )
19881985
* @endcode
19891986
*
19901987
* 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
19961993
* These idle tasks are created to ensure that each core has an idle task to run when
19971994
* no other task is available to run.
19981995
*
1999-
* The function vApplicationGetIdleTaskMemory is called with xCoreID 0 to get the
2000-
* memory for Active idle task. It is called with xCoreID 1, 2 ... ( configNUMBER_OF_CORES - 1 )
2001-
* to get memory for passive idle tasks.
1996+
* The function vApplicationGetPassiveIdleTaskMemory is called with passive idle
1997+
* task index 0, 1 ... ( configNUMBER_OF_CORES - 2 ) to get memory for passive idle
1998+
* tasks.
20021999
*
20032000
* @param ppxIdleTaskTCBBuffer A handle to a statically allocated TCB buffer
20042001
* @param ppxIdleTaskStackBuffer A handle to a statically allocated Stack buffer for the idle task
20052002
* @param pulIdleTaskStackSize A pointer to the number of elements that will fit in the allocated stack buffer
2006-
* @param xCoreId The core index of the idle task buffer
2007-
*/
2008-
void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer,
2009-
StackType_t ** ppxIdleTaskStackBuffer,
2010-
uint32_t * pulIdleTaskStackSize, /*lint !e526 Symbol not defined as it is an application callback. */
2011-
BaseType_t xCoreID );
2012-
#endif /* #if ( configNUMBER_OF_CORES == 1 ) */
2003+
* @param xPassiveIdleTaskIndex The passive idle task index of the idle task buffer
2004+
*/
2005+
#if ( configNUMBER_OF_CORES > 1 )
2006+
void vApplicationGetPassiveIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer,
2007+
StackType_t ** ppxIdleTaskStackBuffer,
2008+
uint32_t * pulIdleTaskStackSize,
2009+
BaseType_t xPassiveIdleTaskIndex );
2010+
#endif /* #if ( configNUMBER_OF_CORES > 1 ) */
20132011
#endif /* if ( configSUPPORT_STATIC_ALLOCATION == 1 ) */
20142012

20152013
/**

tasks.c

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3575,10 +3575,21 @@ static BaseType_t prvCreateIdleTasks( void )
35753575
/* The Idle task is created using user provided RAM - obtain the
35763576
* address of the RAM then create the idle task. */
35773577
#if ( configNUMBER_OF_CORES == 1 )
3578+
{
35783579
vApplicationGetIdleTaskMemory( &pxIdleTaskTCBBuffer, &pxIdleTaskStackBuffer, &ulIdleTaskStackSize );
3580+
}
35793581
#else
3580-
vApplicationGetIdleTaskMemory( &pxIdleTaskTCBBuffer, &pxIdleTaskStackBuffer, &ulIdleTaskStackSize, xCoreID );
3581-
#endif
3582+
{
3583+
if( xCoreID == 0 )
3584+
{
3585+
vApplicationGetIdleTaskMemory( &pxIdleTaskTCBBuffer, &pxIdleTaskStackBuffer, &ulIdleTaskStackSize );
3586+
}
3587+
else
3588+
{
3589+
vApplicationGetPassiveIdleTaskMemory( &pxIdleTaskTCBBuffer, &pxIdleTaskStackBuffer, &ulIdleTaskStackSize, xCoreID - 1 );
3590+
}
3591+
}
3592+
#endif /* if ( configNUMBER_OF_CORES == 1 ) */
35823593
xIdleTaskHandles[ xCoreID ] = xTaskCreateStatic( pxIdleTaskFunction,
35833594
cIdleName,
35843595
ulIdleTaskStackSize,
@@ -8523,36 +8534,34 @@ static void prvAddCurrentTaskToDelayedList( TickType_t xTicksToWait,
85238534
* it's own implementation of vApplicationGetIdleTaskMemory by setting
85248535
* configKERNEL_PROVIDED_STATIC_MEMORY to 0 or leaving it undefined.
85258536
*/
8526-
#if ( configNUMBER_OF_CORES == 1 )
8527-
8528-
void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer,
8529-
StackType_t ** ppxIdleTaskStackBuffer,
8530-
uint32_t * pulIdleTaskStackSize )
8531-
{
8532-
static StaticTask_t xIdleTaskTCB;
8533-
static StackType_t uxIdleTaskStack[ configMINIMAL_STACK_SIZE ];
8537+
void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer,
8538+
StackType_t ** ppxIdleTaskStackBuffer,
8539+
uint32_t * pulIdleTaskStackSize )
8540+
{
8541+
static StaticTask_t xIdleTaskTCB;
8542+
static StackType_t uxIdleTaskStack[ configMINIMAL_STACK_SIZE ];
85348543

8535-
*ppxIdleTaskTCBBuffer = &( xIdleTaskTCB );
8536-
*ppxIdleTaskStackBuffer = &( uxIdleTaskStack[ 0 ] );
8537-
*pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;
8538-
}
8544+
*ppxIdleTaskTCBBuffer = &( xIdleTaskTCB );
8545+
*ppxIdleTaskStackBuffer = &( uxIdleTaskStack[ 0 ] );
8546+
*pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;
8547+
}
85398548

8540-
#else /* #if ( configNUMBER_OF_CORES == 1 ) */
8549+
#if ( configNUMBER_OF_CORES > 1 )
85418550

8542-
void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer,
8543-
StackType_t ** ppxIdleTaskStackBuffer,
8544-
uint32_t * pulIdleTaskStackSize,
8545-
BaseType_t xCoreId )
8551+
void vApplicationGetPassiveIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer,
8552+
StackType_t ** ppxIdleTaskStackBuffer,
8553+
uint32_t * pulIdleTaskStackSize,
8554+
BaseType_t xPassiveIdleTaskIndex )
85468555
{
8547-
static StaticTask_t xIdleTaskTCBs[ configNUMBER_OF_CORES ];
8548-
static StackType_t uxIdleTaskStacks[ configNUMBER_OF_CORES ][ configMINIMAL_STACK_SIZE ];
8556+
static StaticTask_t xIdleTaskTCBs[ configNUMBER_OF_CORES - 1 ];
8557+
static StackType_t uxIdleTaskStacks[ configNUMBER_OF_CORES - 1 ][ configMINIMAL_STACK_SIZE ];
85498558

8550-
*ppxIdleTaskTCBBuffer = &( xIdleTaskTCBs[ xCoreId ] );
8551-
*ppxIdleTaskStackBuffer = &( uxIdleTaskStacks[ xCoreId ][ 0 ] );
8559+
*ppxIdleTaskTCBBuffer = &( xIdleTaskTCBs[ xPassiveIdleTaskIndex ] );
8560+
*ppxIdleTaskStackBuffer = &( uxIdleTaskStacks[ xPassiveIdleTaskIndex ][ 0 ] );
85528561
*pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;
85538562
}
85548563

8555-
#endif /* #if ( configNUMBER_OF_CORES == 1 ) */
8564+
#endif /* #if ( configNUMBER_OF_CORES > 1 ) */
85568565

85578566
#endif /* #if ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configKERNEL_PROVIDED_STATIC_MEMORY == 1 ) && ( portUSING_MPU_WRAPPERS == 0 ) ) */
85588567
/*-----------------------------------------------------------*/

0 commit comments

Comments
 (0)