Merge branch 'feature/freertos_vtasklist_xcoreid' into 'master'

freertos: Add option to display xCoreID in vTaskList

See merge request idf/esp-idf!2728
This commit is contained in:
Ivan Grokhotkov 2018-07-20 18:46:41 +08:00
commit 0e3694b542
7 changed files with 34 additions and 2 deletions

View file

@ -305,6 +305,14 @@ config FREERTOS_USE_STATS_FORMATTING_FUNCTIONS
FreeRTOS. This will allow the usage of stats formatting functions such FreeRTOS. This will allow the usage of stats formatting functions such
as vTaskList(). 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 config FREERTOS_GENERATE_RUN_TIME_STATS
bool "Enable FreeRTOS to collect run time stats" bool "Enable FreeRTOS to collect run time stats"
default n default n

View file

@ -740,6 +740,10 @@ extern "C" {
#define configUSE_STATS_FORMATTING_FUNCTIONS 0 #define configUSE_STATS_FORMATTING_FUNCTIONS 0
#endif #endif
#ifndef configTASKLIST_INCLUDE_COREID
#define configTASKLIST_INCLUDE_COREID 0
#endif
#ifndef portASSERT_IF_INTERRUPT_PRIORITY_INVALID #ifndef portASSERT_IF_INTERRUPT_PRIORITY_INVALID
#define portASSERT_IF_INTERRUPT_PRIORITY_INVALID() #define portASSERT_IF_INTERRUPT_PRIORITY_INVALID()
#endif #endif

View file

@ -211,6 +211,10 @@ int xt_clock_freq(void) __attribute__((deprecated));
#define configUSE_STATS_FORMATTING_FUNCTIONS 1 /* Used by vTaskList() */ #define configUSE_STATS_FORMATTING_FUNCTIONS 1 /* Used by vTaskList() */
#endif #endif
#ifdef CONFIG_FREERTOS_VTASKLIST_INCLUDE_COREID
#define configTASKLIST_INCLUDE_COREID 1
#endif
#ifdef CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS #ifdef CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS
#define configGENERATE_RUN_TIME_STATS 1 /* Used by vTaskGetRunTimeStats() */ #define configGENERATE_RUN_TIME_STATS 1 /* Used by vTaskGetRunTimeStats() */
#endif #endif

View file

@ -181,6 +181,9 @@ 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. */ 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. */ 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. */ 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. */
#if configTASKLIST_INCLUDE_COREID
BaseType_t xCoreID; /*!< Core this task is pinned to. This field is present if CONFIG_FREERTOS_VTASKLIST_INCLUDE_COREID is set. */
#endif
} TaskStatus_t; } TaskStatus_t;
/** /**

View file

@ -3785,6 +3785,10 @@ BaseType_t xTaskGetAffinity( TaskHandle_t xTask )
pxTaskStatusArray[ uxTask ].eCurrentState = eState; pxTaskStatusArray[ uxTask ].eCurrentState = eState;
pxTaskStatusArray[ uxTask ].uxCurrentPriority = pxNextTCB->uxPriority; pxTaskStatusArray[ uxTask ].uxCurrentPriority = pxNextTCB->uxPriority;
#if ( configTASKLIST_INCLUDE_COREID == 1 )
pxTaskStatusArray[ uxTask ].xCoreID = pxNextTCB->xCoreID;
#endif /* configTASKLIST_INCLUDE_COREID */
#if ( INCLUDE_vTaskSuspend == 1 ) #if ( INCLUDE_vTaskSuspend == 1 )
{ {
/* If the task is in the suspended list then there is a chance /* If the task is in the suspended list then there is a chance
@ -4449,7 +4453,11 @@ For ESP32 FreeRTOS, vTaskExitCritical implements both portEXIT_CRITICAL and port
pcWriteBuffer = prvWriteNameToBuffer( pcWriteBuffer, pxTaskStatusArray[ x ].pcTaskName ); pcWriteBuffer = prvWriteNameToBuffer( pcWriteBuffer, pxTaskStatusArray[ x ].pcTaskName );
/* Write the rest of the string. */ /* Write the rest of the string. */
#if configTASKLIST_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 ); 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 ); pcWriteBuffer += strlen( pcWriteBuffer );
} }

View file

@ -199,7 +199,8 @@ PREDEFINED = \
configUSE_RECURSIVE_MUTEXES=1 \ configUSE_RECURSIVE_MUTEXES=1 \
configTHREAD_LOCAL_STORAGE_DELETE_CALLBACKS=1 \ configTHREAD_LOCAL_STORAGE_DELETE_CALLBACKS=1 \
configNUM_THREAD_LOCAL_STORAGE_POINTERS=1 \ configNUM_THREAD_LOCAL_STORAGE_POINTERS=1 \
configUSE_APPLICATION_TASK_TAG=1 configUSE_APPLICATION_TASK_TAG=1 \
configTASKLIST_INCLUDE_COREID=1
## Do not complain about not having dot ## Do not complain about not having dot
## ##

View file

@ -94,7 +94,11 @@ static int tasks_info(int argc, char** argv)
ESP_LOGE(__func__, "failed to allocate buffer for vTaskList output"); ESP_LOGE(__func__, "failed to allocate buffer for vTaskList output");
return 1; return 1;
} }
fputs("Task Name\tStatus\tPrio\tHWM\tTask Number\n", stdout); fputs("Task Name\tStatus\tPrio\tHWM\tTask#", stdout);
#ifdef CONFIG_FREERTOS_VTASKLIST_INCLUDE_COREID
fputs("\tAffinity", stdout);
#endif
fputs("\n", stdout);
vTaskList(task_list_buffer); vTaskList(task_list_buffer);
fputs(task_list_buffer, stdout); fputs(task_list_buffer, stdout);
free(task_list_buffer); free(task_list_buffer);