From 0fb19454820afb31736c95770a2862d183f01bd2 Mon Sep 17 00:00:00 2001 From: Dave McNaughton Date: Thu, 14 Jun 2018 20:37:52 +1000 Subject: [PATCH] Added: display xCoreID in vTaskList Merges https://github.com/espressif/esp-idf/pull/2064 --- components/freertos/Kconfig | 8 ++++++++ components/freertos/include/freertos/task.h | 1 + components/freertos/tasks.c | 5 +++++ 3 files changed, 14 insertions(+) diff --git a/components/freertos/Kconfig b/components/freertos/Kconfig index 1a037377c8..16c7c4bc87 100644 --- a/components/freertos/Kconfig +++ b/components/freertos/Kconfig @@ -305,6 +305,14 @@ config FREERTOS_USE_STATS_FORMATTING_FUNCTIONS FreeRTOS. This will allow the usage of stats formatting functions such as vTaskList(). +config FREERTOS_VTASKLIST_INCLUDE_COREID + bool "Enable display of xCoreID in vTaskList" + depends on FREERTOS_USE_STATS_FORMATTING_FUNCTIONS + default n + help + If enabled, this will include an extra column when vTaskList is called + to display the CoreID the task is pinned to (0,1) or -1 if not pinned. + config FREERTOS_GENERATE_RUN_TIME_STATS bool "Enable FreeRTOS to collect run time stats" default n diff --git a/components/freertos/include/freertos/task.h b/components/freertos/include/freertos/task.h index ab605bb301..c548c945fd 100644 --- a/components/freertos/include/freertos/task.h +++ b/components/freertos/include/freertos/task.h @@ -181,6 +181,7 @@ typedef struct xTASK_STATUS uint32_t ulRunTimeCounter; /*!< The total run time allocated to the task so far, as defined by the run time stats clock. See http://www.freertos.org/rtos-run-time-stats.html. Only valid when configGENERATE_RUN_TIME_STATS is defined as 1 in FreeRTOSConfig.h. */ StackType_t *pxStackBase; /*!< Points to the lowest address of the task's stack area. */ uint32_t usStackHighWaterMark; /*!< The minimum amount of stack space that has remained for the task since the task was created. The closer this value is to zero the closer the task has come to overflowing its stack. */ + BaseType_t xCoreID; /*!< Core this task is pinned to */ } TaskStatus_t; /** diff --git a/components/freertos/tasks.c b/components/freertos/tasks.c index fe081975dd..1265583b7e 100644 --- a/components/freertos/tasks.c +++ b/components/freertos/tasks.c @@ -3784,6 +3784,7 @@ BaseType_t xTaskGetAffinity( TaskHandle_t xTask ) pxTaskStatusArray[ uxTask ].xTaskNumber = pxNextTCB->uxTCBNumber; pxTaskStatusArray[ uxTask ].eCurrentState = eState; pxTaskStatusArray[ uxTask ].uxCurrentPriority = pxNextTCB->uxPriority; + pxTaskStatusArray[ uxTask ].xCoreID = pxNextTCB->xCoreID; #if ( INCLUDE_vTaskSuspend == 1 ) { @@ -4449,7 +4450,11 @@ For ESP32 FreeRTOS, vTaskExitCritical implements both portEXIT_CRITICAL and port pcWriteBuffer = prvWriteNameToBuffer( pcWriteBuffer, pxTaskStatusArray[ x ].pcTaskName ); /* Write the rest of the string. */ +#ifdef CONFIG_FREERTOS_VTASKLIST_INCLUDE_COREID + sprintf( pcWriteBuffer, "\t%c\t%u\t%u\t%u\t%hd\r\n", cStatus, ( unsigned int ) pxTaskStatusArray[ x ].uxCurrentPriority, ( unsigned int ) pxTaskStatusArray[ x ].usStackHighWaterMark, ( unsigned int ) pxTaskStatusArray[ x ].xTaskNumber, ( int ) pxTaskStatusArray[ x ].xCoreID ); +#else sprintf( pcWriteBuffer, "\t%c\t%u\t%u\t%u\r\n", cStatus, ( unsigned int ) pxTaskStatusArray[ x ].uxCurrentPriority, ( unsigned int ) pxTaskStatusArray[ x ].usStackHighWaterMark, ( unsigned int ) pxTaskStatusArray[ x ].xTaskNumber ); +#endif pcWriteBuffer += strlen( pcWriteBuffer ); }