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
|
||||
#define traceENTER_xTaskGetIdleTaskHandle()
|
||||
#endif
|
||||
#else
|
||||
#ifndef traceENTER_xTaskGetIdleTaskHandle
|
||||
#define traceENTER_xTaskGetIdleTaskHandle( xCoreID )
|
||||
#endif
|
||||
|
||||
#if ( configNUMBER_OF_CORES == 1 )
|
||||
#ifndef traceRETURN_xTaskGetIdleTaskHandle
|
||||
#define traceRETURN_xTaskGetIdleTaskHandle( xIdleTaskHandle )
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef traceRETURN_xTaskGetIdleTaskHandle
|
||||
#define traceRETURN_xTaskGetIdleTaskHandle( xIdleTaskHandle )
|
||||
#ifndef traceENTER_xTaskGetIdleTaskHandleForCore
|
||||
#define traceENTER_xTaskGetIdleTaskHandleForCore( xCoreID )
|
||||
#endif
|
||||
|
||||
#ifndef traceRETURN_xTaskGetIdleTaskHandleForCore
|
||||
#define traceRETURN_xTaskGetIdleTaskHandleForCore( xIdleTaskHandle )
|
||||
#endif
|
||||
|
||||
#ifndef traceENTER_vTaskStepTick
|
||||
|
|
|
@ -2030,24 +2030,23 @@ BaseType_t xTaskCallApplicationTaskHook( TaskHandle_t xTask,
|
|||
* xTaskGetIdleTaskHandle() is only available if
|
||||
* INCLUDE_xTaskGetIdleTaskHandle is set to 1 in FreeRTOSConfig.h.
|
||||
*
|
||||
* Simply returns the handle of the idle task. It is not valid to call
|
||||
* xTaskGetIdleTaskHandle() before the scheduler has been started.
|
||||
* In single-core FreeRTOS, this function simply returns the handle of the idle
|
||||
* 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:
|
||||
* 1. 1 Active idle task which does all the housekeeping.
|
||||
* 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
|
||||
* no other task is available to run.
|
||||
*
|
||||
* Set xCoreID to 0 to get the Active idle task handle. Set xCoreID to
|
||||
* 1,2 ... ( configNUMBER_OF_CORES - 1 ) to get the Passive idle task
|
||||
* handles.
|
||||
* no other task is available to run. Call xTaskGetIdleTaskHandle() or
|
||||
* xTaskGetIdleTaskHandleForCore() with xCoreID set to 0 to get the Active
|
||||
* idle task handle. Call xTaskGetIdleTaskHandleForCore() with xCoreID set to
|
||||
* 1,2 ... ( configNUMBER_OF_CORES - 1 ) to get the Passive idle task handles.
|
||||
*/
|
||||
#if ( configNUMBER_OF_CORES == 1 )
|
||||
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 ) */
|
||||
TaskHandle_t xTaskGetIdleTaskHandleForCore( BaseType_t xCoreID ) PRIVILEGED_FUNCTION;
|
||||
|
||||
/**
|
||||
* configUSE_TRACE_FACILITY must be defined as 1 in FreeRTOSConfig.h for
|
||||
|
|
12
tasks.c
12
tasks.c
|
@ -4472,7 +4472,6 @@ char * pcTaskGetName( TaskHandle_t xTaskToQuery ) /*lint !e971 Unqualified char
|
|||
#if ( INCLUDE_xTaskGetIdleTaskHandle == 1 )
|
||||
|
||||
#if ( configNUMBER_OF_CORES == 1 )
|
||||
|
||||
TaskHandle_t xTaskGetIdleTaskHandle( void )
|
||||
{
|
||||
traceENTER_xTaskGetIdleTaskHandle();
|
||||
|
@ -4485,12 +4484,11 @@ char * pcTaskGetName( TaskHandle_t xTaskToQuery ) /*lint !e971 Unqualified char
|
|||
|
||||
return xIdleTaskHandles[ 0 ];
|
||||
}
|
||||
#endif /* if ( configNUMBER_OF_CORES == 1 ) */
|
||||
|
||||
#else /* if ( configNUMBER_OF_CORES == 1 ) */
|
||||
|
||||
TaskHandle_t xTaskGetIdleTaskHandle( BaseType_t xCoreID )
|
||||
TaskHandle_t xTaskGetIdleTaskHandleForCore( BaseType_t xCoreID )
|
||||
{
|
||||
traceENTER_xTaskGetIdleTaskHandle( xCoreID );
|
||||
traceENTER_xTaskGetIdleTaskHandleForCore( xCoreID );
|
||||
|
||||
/* Ensure the core ID is valid. */
|
||||
configASSERT( taskVALID_CORE_ID( xCoreID ) == pdTRUE );
|
||||
|
@ -4499,13 +4497,11 @@ char * pcTaskGetName( TaskHandle_t xTaskToQuery ) /*lint !e971 Unqualified char
|
|||
* started, then xIdleTaskHandles will be NULL. */
|
||||
configASSERT( ( xIdleTaskHandles[ xCoreID ] != NULL ) );
|
||||
|
||||
traceRETURN_xTaskGetIdleTaskHandle( xIdleTaskHandles[ xCoreID ] );
|
||||
traceRETURN_xTaskGetIdleTaskHandleForCore( xIdleTaskHandles[ xCoreID ] );
|
||||
|
||||
return xIdleTaskHandles[ xCoreID ];
|
||||
}
|
||||
|
||||
#endif /* if ( configNUMBER_OF_CORES == 1 ) */
|
||||
|
||||
#endif /* INCLUDE_xTaskGetIdleTaskHandle */
|
||||
/*----------------------------------------------------------*/
|
||||
|
||||
|
|
Loading…
Reference in a new issue