mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-06-05 11:59:05 -04:00
Update xTaskGetIdleTaskHandle() For SMP (#868)
* Update xTaskGetIdleTaskHandle() in SMP This commit updates xTaskGetIdleTaskHandle() for SMP in the following ways: - xTaskGetIdleTaskHandle() no longer accepts xCoreID argument in SMP so that there is not change in API between single-core and SMP - xTaskGetIdleTaskHandle() now returns the Active idle task handle in SMP, which matches the behavior in single-core. - Added xTaskGetIdleTaskHandleForCore() in SMP which accepts an xCoreID argument. This function can be used to obtain the Passive idle task handles. * Update xTaskGetIdleTaskHandle --------- Co-authored-by: Ching-Hsin Lee <chinglee@amazon.com> Co-authored-by: chinglee-iot <61685396+chinglee-iot@users.noreply.github.com> Co-authored-by: Rahul Kar <118818625+kar-rahul-aws@users.noreply.github.com> Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com>
This commit is contained in:
parent
c0ce725293
commit
cd5c774b2b
|
@ -1886,14 +1886,20 @@
|
||||||
#ifndef traceENTER_xTaskGetIdleTaskHandle
|
#ifndef traceENTER_xTaskGetIdleTaskHandle
|
||||||
#define traceENTER_xTaskGetIdleTaskHandle()
|
#define traceENTER_xTaskGetIdleTaskHandle()
|
||||||
#endif
|
#endif
|
||||||
#else
|
#endif
|
||||||
#ifndef traceENTER_xTaskGetIdleTaskHandle
|
|
||||||
#define traceENTER_xTaskGetIdleTaskHandle( xCoreID )
|
#if ( configNUMBER_OF_CORES == 1 )
|
||||||
|
#ifndef traceRETURN_xTaskGetIdleTaskHandle
|
||||||
|
#define traceRETURN_xTaskGetIdleTaskHandle( xIdleTaskHandle )
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef traceRETURN_xTaskGetIdleTaskHandle
|
#ifndef traceENTER_xTaskGetIdleTaskHandleForCore
|
||||||
#define traceRETURN_xTaskGetIdleTaskHandle( xIdleTaskHandle )
|
#define traceENTER_xTaskGetIdleTaskHandleForCore( xCoreID )
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef traceRETURN_xTaskGetIdleTaskHandleForCore
|
||||||
|
#define traceRETURN_xTaskGetIdleTaskHandleForCore( xIdleTaskHandle )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef traceENTER_vTaskStepTick
|
#ifndef traceENTER_vTaskStepTick
|
||||||
|
|
|
@ -2030,24 +2030,23 @@ BaseType_t xTaskCallApplicationTaskHook( TaskHandle_t xTask,
|
||||||
* xTaskGetIdleTaskHandle() is only available if
|
* xTaskGetIdleTaskHandle() is only available if
|
||||||
* INCLUDE_xTaskGetIdleTaskHandle is set to 1 in FreeRTOSConfig.h.
|
* INCLUDE_xTaskGetIdleTaskHandle is set to 1 in FreeRTOSConfig.h.
|
||||||
*
|
*
|
||||||
* Simply returns the handle of the idle task. It is not valid to call
|
* In single-core FreeRTOS, this function simply returns the handle of the idle
|
||||||
* xTaskGetIdleTaskHandle() before the scheduler has been started.
|
* task. It is not valid to call xTaskGetIdleTaskHandle() before the scheduler
|
||||||
|
* has been started.
|
||||||
*
|
*
|
||||||
* In the FreeRTOS SMP, there are a total of configNUMBER_OF_CORES idle tasks:
|
* In the FreeRTOS SMP, there are a total of configNUMBER_OF_CORES idle tasks:
|
||||||
* 1. 1 Active idle task which does all the housekeeping.
|
* 1. 1 Active idle task which does all the housekeeping.
|
||||||
* 2. ( configNUMBER_OF_CORES - 1 ) Passive idle tasks which do nothing.
|
* 2. ( configNUMBER_OF_CORES - 1 ) Passive idle tasks which do nothing.
|
||||||
* 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. Call xTaskGetIdleTaskHandle() or
|
||||||
*
|
* xTaskGetIdleTaskHandleForCore() with xCoreID set to 0 to get the Active
|
||||||
* Set xCoreID to 0 to get the Active idle task handle. Set xCoreID to
|
* idle task handle. Call xTaskGetIdleTaskHandleForCore() with xCoreID set to
|
||||||
* 1,2 ... ( configNUMBER_OF_CORES - 1 ) to get the Passive idle task
|
* 1,2 ... ( configNUMBER_OF_CORES - 1 ) to get the Passive idle task handles.
|
||||||
* handles.
|
|
||||||
*/
|
*/
|
||||||
#if ( configNUMBER_OF_CORES == 1 )
|
#if ( configNUMBER_OF_CORES == 1 )
|
||||||
TaskHandle_t xTaskGetIdleTaskHandle( void ) PRIVILEGED_FUNCTION;
|
TaskHandle_t xTaskGetIdleTaskHandle( void ) PRIVILEGED_FUNCTION;
|
||||||
#else /* #if ( configNUMBER_OF_CORES == 1 ) */
|
|
||||||
TaskHandle_t xTaskGetIdleTaskHandle( BaseType_t xCoreID ) PRIVILEGED_FUNCTION;
|
|
||||||
#endif /* #if ( configNUMBER_OF_CORES == 1 ) */
|
#endif /* #if ( configNUMBER_OF_CORES == 1 ) */
|
||||||
|
TaskHandle_t xTaskGetIdleTaskHandleForCore( BaseType_t xCoreID ) PRIVILEGED_FUNCTION;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* configUSE_TRACE_FACILITY must be defined as 1 in FreeRTOSConfig.h for
|
* configUSE_TRACE_FACILITY must be defined as 1 in FreeRTOSConfig.h for
|
||||||
|
|
36
tasks.c
36
tasks.c
|
@ -4472,7 +4472,6 @@ char * pcTaskGetName( TaskHandle_t xTaskToQuery ) /*lint !e971 Unqualified char
|
||||||
#if ( INCLUDE_xTaskGetIdleTaskHandle == 1 )
|
#if ( INCLUDE_xTaskGetIdleTaskHandle == 1 )
|
||||||
|
|
||||||
#if ( configNUMBER_OF_CORES == 1 )
|
#if ( configNUMBER_OF_CORES == 1 )
|
||||||
|
|
||||||
TaskHandle_t xTaskGetIdleTaskHandle( void )
|
TaskHandle_t xTaskGetIdleTaskHandle( void )
|
||||||
{
|
{
|
||||||
traceENTER_xTaskGetIdleTaskHandle();
|
traceENTER_xTaskGetIdleTaskHandle();
|
||||||
|
@ -4485,27 +4484,24 @@ char * pcTaskGetName( TaskHandle_t xTaskToQuery ) /*lint !e971 Unqualified char
|
||||||
|
|
||||||
return xIdleTaskHandles[ 0 ];
|
return xIdleTaskHandles[ 0 ];
|
||||||
}
|
}
|
||||||
|
|
||||||
#else /* if ( configNUMBER_OF_CORES == 1 ) */
|
|
||||||
|
|
||||||
TaskHandle_t xTaskGetIdleTaskHandle( BaseType_t xCoreID )
|
|
||||||
{
|
|
||||||
traceENTER_xTaskGetIdleTaskHandle( xCoreID );
|
|
||||||
|
|
||||||
/* Ensure the core ID is valid. */
|
|
||||||
configASSERT( taskVALID_CORE_ID( xCoreID ) == pdTRUE );
|
|
||||||
|
|
||||||
/* If xTaskGetIdleTaskHandle() is called before the scheduler has been
|
|
||||||
* started, then xIdleTaskHandles will be NULL. */
|
|
||||||
configASSERT( ( xIdleTaskHandles[ xCoreID ] != NULL ) );
|
|
||||||
|
|
||||||
traceRETURN_xTaskGetIdleTaskHandle( xIdleTaskHandles[ xCoreID ] );
|
|
||||||
|
|
||||||
return xIdleTaskHandles[ xCoreID ];
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* if ( configNUMBER_OF_CORES == 1 ) */
|
#endif /* if ( configNUMBER_OF_CORES == 1 ) */
|
||||||
|
|
||||||
|
TaskHandle_t xTaskGetIdleTaskHandleForCore( BaseType_t xCoreID )
|
||||||
|
{
|
||||||
|
traceENTER_xTaskGetIdleTaskHandleForCore( xCoreID );
|
||||||
|
|
||||||
|
/* Ensure the core ID is valid. */
|
||||||
|
configASSERT( taskVALID_CORE_ID( xCoreID ) == pdTRUE );
|
||||||
|
|
||||||
|
/* If xTaskGetIdleTaskHandle() is called before the scheduler has been
|
||||||
|
* started, then xIdleTaskHandles will be NULL. */
|
||||||
|
configASSERT( ( xIdleTaskHandles[ xCoreID ] != NULL ) );
|
||||||
|
|
||||||
|
traceRETURN_xTaskGetIdleTaskHandleForCore( xIdleTaskHandles[ xCoreID ] );
|
||||||
|
|
||||||
|
return xIdleTaskHandles[ xCoreID ];
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* INCLUDE_xTaskGetIdleTaskHandle */
|
#endif /* INCLUDE_xTaskGetIdleTaskHandle */
|
||||||
/*----------------------------------------------------------*/
|
/*----------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue