From df0b764ed64381166bd6d9887a82cca5b3c514d3 Mon Sep 17 00:00:00 2001 From: schilkp Date: Wed, 5 Jun 2024 10:00:34 +0200 Subject: [PATCH] Add traceSTARTING_SCHEDULER tracing hook. Discussed here: https://forums.freertos.org/t/tracing-improvements/20097 This hook enables tracers to run code on startup after all RTOS resources are created and to detect that the scheduler is starting without relying on traceENTER/traceEXIT macros. It also provides tracers access to the task handle of all IDLE tasks, allowing them to be identified unambiguously and without relying on INCLUDE_xTaskGetIdleTaskHandle. --- include/FreeRTOS.h | 7 +++++++ tasks.c | 2 ++ 2 files changed, 9 insertions(+) diff --git a/include/FreeRTOS.h b/include/FreeRTOS.h index b972ffd10..be6595eb7 100644 --- a/include/FreeRTOS.h +++ b/include/FreeRTOS.h @@ -621,6 +621,13 @@ #define traceTASK_SWITCHED_IN() #endif +#ifndef traceSTARTING_SCHEDULER + +/* Called after all idle tasks and timer task (if enabled) have been created + * succesfully, just before the scheduler is started. */ + #define traceSTARTING_SCHEDULER( xIdleTaskHandles ) +#endif + #ifndef traceINCREASE_TICK_COUNT /* Called before stepping the tick count after waking from tickless idle diff --git a/tasks.c b/tasks.c index a049d64fe..16ed290f4 100644 --- a/tasks.c +++ b/tasks.c @@ -3735,6 +3735,8 @@ void vTaskStartScheduler( void ) /* Setting up the timer tick is hardware specific and thus in the * portable interface. */ + traceSTARTING_SCHEDULER( xIdleTaskHandles ); + /* The return value for xPortStartScheduler is not required * hence using a void datatype. */ ( void ) xPortStartScheduler();