From 74fc6623785210f47eba01703b6e063c927d73eb Mon Sep 17 00:00:00 2001 From: Sudeep Mohanty Date: Mon, 10 Oct 2022 13:07:48 +0200 Subject: [PATCH 1/2] Add support for retrieving a task's uxCoreAffinityMask with the vTaskGetInfo() API This commit adds support for retrieving the task's core affinity mask when SMP is used for more than 1 cores and configUSE_CORE_AFFINITY is enabled. Signed-off-by: Sudeep Mohanty --- include/task.h | 3 +++ tasks.c | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/include/task.h b/include/task.h index 65cd86e8dd..5942ad1f2c 100644 --- a/include/task.h +++ b/include/task.h @@ -153,6 +153,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 https://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. */ configSTACK_DEPTH_TYPE 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 ( configUSE_CORE_AFFINITY == 1 && configNUM_CORES > 1 ) + UBaseType_t uxCoreAffinityMask; /* The core affinity mask for the task */ +#endif } TaskStatus_t; /* Possible return values for eTaskConfirmSleepModeStatus(). */ diff --git a/tasks.c b/tasks.c index 046aed9aac..cf4952ec62 100644 --- a/tasks.c +++ b/tasks.c @@ -4708,6 +4708,12 @@ static void prvCheckTasksWaitingTermination( void ) pxTaskStatus->pxStackBase = pxTCB->pxStack; pxTaskStatus->xTaskNumber = pxTCB->uxTCBNumber; + #if ( configUSE_CORE_AFFINITY == 1 && configNUM_CORES > 1 ) + { + pxTaskStatus->uxCoreAffinityMask = pxTCB->uxCoreAffinityMask; + } + #endif + #if ( configUSE_MUTEXES == 1 ) { pxTaskStatus->uxBasePriority = pxTCB->uxBasePriority; From bd6aed0adf3c47b87ae4ca27b0f944536bc0d620 Mon Sep 17 00:00:00 2001 From: Sudeep Mohanty <91244425+sudeep-mohanty@users.noreply.github.com> Date: Wed, 12 Oct 2022 09:39:41 +0200 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com> --- include/task.h | 2 +- tasks.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/task.h b/include/task.h index 5942ad1f2c..ba82f9f0da 100644 --- a/include/task.h +++ b/include/task.h @@ -153,7 +153,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 https://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. */ configSTACK_DEPTH_TYPE 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 ( configUSE_CORE_AFFINITY == 1 && configNUM_CORES > 1 ) +#if ( ( configUSE_CORE_AFFINITY == 1 ) && ( configNUM_CORES > 1 ) ) UBaseType_t uxCoreAffinityMask; /* The core affinity mask for the task */ #endif } TaskStatus_t; diff --git a/tasks.c b/tasks.c index cf4952ec62..842ef224e9 100644 --- a/tasks.c +++ b/tasks.c @@ -4708,7 +4708,7 @@ static void prvCheckTasksWaitingTermination( void ) pxTaskStatus->pxStackBase = pxTCB->pxStack; pxTaskStatus->xTaskNumber = pxTCB->uxTCBNumber; - #if ( configUSE_CORE_AFFINITY == 1 && configNUM_CORES > 1 ) + #if ( ( configUSE_CORE_AFFINITY == 1 ) && ( configNUM_CORES > 1 ) ) { pxTaskStatus->uxCoreAffinityMask = pxTCB->uxCoreAffinityMask; }