Add uxTaskCallForEachTask, and refactor uxTaskGetSystemState to use it. (#1439)

---------

Co-authored-by: Anubhav Rawal <rawalexe@amazon.com>
Co-authored-by: Kody Stribrny <kstribrn@amazon.com>
This commit is contained in:
Dave Nadler 2026-07-23 12:04:42 -04:00 • committed by GitHub
parent 78069a79ea
commit 5706e10cb4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 148 additions and 75 deletions

View file

@ -184,6 +184,13 @@ typedef struct xTASK_STATUS
#endif
} TaskStatus_t;
/* Callback type used by uxTaskCallForEachTask(). The callback receives one
* task handle and state at a time, plus an opaque caller-supplied context
* pointer. The callback may call vTaskGetInfo() if it needs a TaskStatus_t. */
typedef void (* TaskStatusCallbackFunction_t)( TaskHandle_t xTask,
eTaskState eState,
void * pvCallbackContext );
/* Possible return values for eTaskConfirmSleepModeStatus(). */
typedef enum
{
@ -2210,7 +2217,38 @@ char * pcTaskGetName( TaskHandle_t xTaskToQuery ) PRIVILEGED_FUNCTION;
UBaseType_t uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray,
const UBaseType_t uxArraySize,
configRUN_TIME_COUNTER_TYPE * const pulTotalRunTime ) PRIVILEGED_FUNCTION;
#endif
/**
* For each task, call pxCallbackFunction with the task's handle and state,
* and the provided context.
*
* NOTE: This function is intended for debugging use only as it suspends
* the scheduler for an extended period. The callback runs while the
* scheduler is suspended, so it must return quickly and must not perform
* blocking operations.
*
* NOTE: This API is privileged-only (it invokes a user callback from
* privileged context).
*
* @param pxCallbackFunction Callback to invoke once for each task (passing
* the task's handle, state, and the pvCallbackContext).
*
* @param pvCallbackContext Opaque caller-provided context passed through to
* each callback invocation.
*
* @param pulTotalRunTime If configGENERATE_RUN_TIME_STATS is set to 1 in
* FreeRTOSConfig.h then *pulTotalRunTime is set to the total run time since
* boot. pulTotalRunTime can be set to NULL to omit the total run time
* information.
*
* @return The number tasks provided to the callback.
*/
UBaseType_t uxTaskCallForEachTask( TaskStatusCallbackFunction_t pxCallbackFunction,
void * pvCallbackContext,
configRUN_TIME_COUNTER_TYPE * const pulTotalRunTime ) PRIVILEGED_FUNCTION;
#endif /* if ( configUSE_TRACE_FACILITY == 1 ) */
/**
* task. h