diff --git a/include/FreeRTOS.h b/include/FreeRTOS.h index b8153ac64..06c50adf3 100644 --- a/include/FreeRTOS.h +++ b/include/FreeRTOS.h @@ -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 diff --git a/include/task.h b/include/task.h index 9ff199287..cb06c2370 100644 --- a/include/task.h +++ b/include/task.h @@ -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 diff --git a/tasks.c b/tasks.c index 4a6c78a8c..a26f8b500 100644 --- a/tasks.c +++ b/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,27 +4484,24 @@ char * pcTaskGetName( TaskHandle_t xTaskToQuery ) /*lint !e971 Unqualified char 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 ) */ + 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 */ /*----------------------------------------------------------*/