Skip to content

Commit

Permalink
Update xTaskGetIdleTaskHandle
Browse files Browse the repository at this point in the history
  • Loading branch information
chinglee-iot authored and Dazza0 committed Nov 16, 2023
1 parent 6f99031 commit b3bd665
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 44 deletions.
22 changes: 11 additions & 11 deletions include/FreeRTOS.h
Original file line number Diff line number Diff line change
Expand Up @@ -1882,24 +1882,24 @@
#define traceRETURN_uxTaskGetSystemState( uxTask )
#endif

#ifndef traceENTER_xTaskGetIdleTaskHandle
#define traceENTER_xTaskGetIdleTaskHandle()
#if ( configNUMBER_OF_CORES == 1 )
#ifndef traceENTER_xTaskGetIdleTaskHandle
#define traceENTER_xTaskGetIdleTaskHandle()
#endif
#endif

#if ( configNUMBER_OF_CORES > 1 )
#ifndef traceENTER_xTaskGetIdleTaskHandleForCore
#define traceENTER_xTaskGetIdleTaskHandleForCore( xCoreID )
#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

#if ( configNUMBER_OF_CORES > 1 )
#ifndef traceRETURN_xTaskGetIdleTaskHandleForCore
#define traceRETURN_xTaskGetIdleTaskHandleForCore( xIdleTaskHandle )
#endif
#ifndef traceRETURN_xTaskGetIdleTaskHandleForCore
#define traceRETURN_xTaskGetIdleTaskHandleForCore( xIdleTaskHandle )
#endif

#ifndef traceENTER_vTaskStepTick
Expand Down
8 changes: 4 additions & 4 deletions include/task.h
Original file line number Diff line number Diff line change
Expand Up @@ -2043,10 +2043,10 @@ BaseType_t xTaskCallApplicationTaskHook( TaskHandle_t xTask,
* idle task handle. Call xTaskGetIdleTaskHandleForCore() with xCoreID set to
* 1,2 ... ( configNUMBER_OF_CORES - 1 ) to get the Passive idle task handles.
*/
TaskHandle_t xTaskGetIdleTaskHandle( void ) PRIVILEGED_FUNCTION;
#if ( configNUMBER_OF_CORES > 1 )
TaskHandle_t xTaskGetIdleTaskHandleForCore( BaseType_t xCoreID ) PRIVILEGED_FUNCTION;
#endif /* #if ( configNUMBER_OF_CORES > 1 ) */
#if ( configNUMBER_OF_CORES == 1 )
TaskHandle_t xTaskGetIdleTaskHandle( void ) 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
Expand Down
41 changes: 12 additions & 29 deletions tasks.c
Original file line number Diff line number Diff line change
Expand Up @@ -4466,7 +4466,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();
Expand All @@ -4479,39 +4478,23 @@ 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( void )
{
traceENTER_xTaskGetIdleTaskHandle();

/* If xTaskGetIdleTaskHandle() is called before the scheduler has been
* started, then xIdleTaskHandles will be NULL. */
configASSERT( ( xIdleTaskHandles[ portGET_CORE_ID() ] != NULL ) );

traceRETURN_xTaskGetIdleTaskHandle( xIdleTaskHandles[ portGET_CORE_ID() ] );

return xIdleTaskHandles[ portGET_CORE_ID() ];
}

TaskHandle_t xTaskGetIdleTaskHandleForCore( BaseType_t xCoreID )
{
traceENTER_xTaskGetIdleTaskHandleForCore( xCoreID );
TaskHandle_t xTaskGetIdleTaskHandleForCore( BaseType_t xCoreID )
{
traceENTER_xTaskGetIdleTaskHandleForCore( xCoreID );

/* Ensure the core ID is valid. */
configASSERT( taskVALID_CORE_ID( xCoreID ) == pdTRUE );
/* 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 ] );
/* If xTaskGetIdleTaskHandle() is called before the scheduler has been
* started, then xIdleTaskHandles will be NULL. */
configASSERT( ( xIdleTaskHandles[ xCoreID ] != NULL ) );

return xIdleTaskHandles[ xCoreID ];
}
traceRETURN_xTaskGetIdleTaskHandleForCore( xIdleTaskHandles[ xCoreID ] );

#endif /* if ( configNUMBER_OF_CORES == 1 ) */
return xIdleTaskHandles[ xCoreID ];
}

#endif /* INCLUDE_xTaskGetIdleTaskHandle */
/*----------------------------------------------------------*/
Expand Down

0 comments on commit b3bd665

Please sign in to comment.