mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-04-19 21:11:57 -04:00
Add option to set the core affinity for the Timer Svc Task on SMP systems (#805)
This PR introduces the configTIMER_SERVICE_TASK_CORE_AFFINITY option which allows the system to configure the core affinity of the Timer Service Task on an SMP system. The default affinity of the Timer Service Task is set to tskNO_AFFINITY which is the current behavior on SMP systems. Signed-off-by: Sudeep Mohanty <sudp.mohanty@gmail.com> Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com>
This commit is contained in:
parent
1b2b0904ce
commit
631ae9e6e4
94
timers.c
94
timers.c
|
@ -60,12 +60,21 @@
|
||||||
#define tmrNO_DELAY ( ( TickType_t ) 0U )
|
#define tmrNO_DELAY ( ( TickType_t ) 0U )
|
||||||
#define tmrMAX_TIME_BEFORE_OVERFLOW ( ( TickType_t ) -1 )
|
#define tmrMAX_TIME_BEFORE_OVERFLOW ( ( TickType_t ) -1 )
|
||||||
|
|
||||||
/* The name assigned to the timer service task. This can be overridden by
|
/* The name assigned to the timer service task. This can be overridden by
|
||||||
* defining trmTIMER_SERVICE_TASK_NAME in FreeRTOSConfig.h. */
|
* defining configTIMER_SERVICE_TASK_NAME in FreeRTOSConfig.h. */
|
||||||
#ifndef configTIMER_SERVICE_TASK_NAME
|
#ifndef configTIMER_SERVICE_TASK_NAME
|
||||||
#define configTIMER_SERVICE_TASK_NAME "Tmr Svc"
|
#define configTIMER_SERVICE_TASK_NAME "Tmr Svc"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if ( ( configNUMBER_OF_CORES > 1 ) && ( configUSE_CORE_AFFINITY == 1 ) )
|
||||||
|
|
||||||
|
/* The core affinity assigned to the timer service task on SMP systems.
|
||||||
|
* This can be overridden by defining configTIMER_SERVICE_TASK_CORE_AFFINITY in FreeRTOSConfig.h. */
|
||||||
|
#ifndef configTIMER_SERVICE_TASK_CORE_AFFINITY
|
||||||
|
#define configTIMER_SERVICE_TASK_CORE_AFFINITY tskNO_AFFINITY
|
||||||
|
#endif
|
||||||
|
#endif /* #if ( ( configNUMBER_OF_CORES > 1 ) && ( configUSE_CORE_AFFINITY == 1 ) ) */
|
||||||
|
|
||||||
/* Bit definitions used in the ucStatus member of a timer structure. */
|
/* Bit definitions used in the ucStatus member of a timer structure. */
|
||||||
#define tmrSTATUS_IS_ACTIVE ( 0x01U )
|
#define tmrSTATUS_IS_ACTIVE ( 0x01U )
|
||||||
#define tmrSTATUS_IS_STATICALLY_ALLOCATED ( 0x02U )
|
#define tmrSTATUS_IS_STATICALLY_ALLOCATED ( 0x02U )
|
||||||
|
@ -245,36 +254,75 @@
|
||||||
|
|
||||||
if( xTimerQueue != NULL )
|
if( xTimerQueue != NULL )
|
||||||
{
|
{
|
||||||
#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
|
#if ( ( configNUMBER_OF_CORES > 1 ) && ( configUSE_CORE_AFFINITY == 1 ) )
|
||||||
{
|
{
|
||||||
StaticTask_t * pxTimerTaskTCBBuffer = NULL;
|
#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
|
||||||
StackType_t * pxTimerTaskStackBuffer = NULL;
|
{
|
||||||
uint32_t ulTimerTaskStackSize;
|
StaticTask_t * pxTimerTaskTCBBuffer = NULL;
|
||||||
|
StackType_t * pxTimerTaskStackBuffer = NULL;
|
||||||
|
uint32_t ulTimerTaskStackSize;
|
||||||
|
|
||||||
vApplicationGetTimerTaskMemory( &pxTimerTaskTCBBuffer, &pxTimerTaskStackBuffer, &ulTimerTaskStackSize );
|
vApplicationGetTimerTaskMemory( &pxTimerTaskTCBBuffer, &pxTimerTaskStackBuffer, &ulTimerTaskStackSize );
|
||||||
xTimerTaskHandle = xTaskCreateStatic( prvTimerTask,
|
xTimerTaskHandle = xTaskCreateStaticAffinitySet( prvTimerTask,
|
||||||
|
configTIMER_SERVICE_TASK_NAME,
|
||||||
|
ulTimerTaskStackSize,
|
||||||
|
NULL,
|
||||||
|
( ( UBaseType_t ) configTIMER_TASK_PRIORITY ) | portPRIVILEGE_BIT,
|
||||||
|
pxTimerTaskStackBuffer,
|
||||||
|
pxTimerTaskTCBBuffer,
|
||||||
|
configTIMER_SERVICE_TASK_CORE_AFFINITY );
|
||||||
|
|
||||||
|
if( xTimerTaskHandle != NULL )
|
||||||
|
{
|
||||||
|
xReturn = pdPASS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else /* if ( configSUPPORT_STATIC_ALLOCATION == 1 ) */
|
||||||
|
{
|
||||||
|
xReturn = xTaskCreateAffinitySet( prvTimerTask,
|
||||||
configTIMER_SERVICE_TASK_NAME,
|
configTIMER_SERVICE_TASK_NAME,
|
||||||
ulTimerTaskStackSize,
|
configTIMER_TASK_STACK_DEPTH,
|
||||||
NULL,
|
NULL,
|
||||||
( ( UBaseType_t ) configTIMER_TASK_PRIORITY ) | portPRIVILEGE_BIT,
|
( ( UBaseType_t ) configTIMER_TASK_PRIORITY ) | portPRIVILEGE_BIT,
|
||||||
pxTimerTaskStackBuffer,
|
configTIMER_SERVICE_TASK_CORE_AFFINITY,
|
||||||
pxTimerTaskTCBBuffer );
|
&xTimerTaskHandle );
|
||||||
|
|
||||||
if( xTimerTaskHandle != NULL )
|
|
||||||
{
|
|
||||||
xReturn = pdPASS;
|
|
||||||
}
|
}
|
||||||
|
#endif /* configSUPPORT_STATIC_ALLOCATION */
|
||||||
}
|
}
|
||||||
#else /* if ( configSUPPORT_STATIC_ALLOCATION == 1 ) */
|
#else /* #if ( ( configNUMBER_OF_CORES > 1 ) && ( configUSE_CORE_AFFINITY == 1 ) ) */
|
||||||
{
|
{
|
||||||
xReturn = xTaskCreate( prvTimerTask,
|
#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
|
||||||
configTIMER_SERVICE_TASK_NAME,
|
{
|
||||||
configTIMER_TASK_STACK_DEPTH,
|
StaticTask_t * pxTimerTaskTCBBuffer = NULL;
|
||||||
NULL,
|
StackType_t * pxTimerTaskStackBuffer = NULL;
|
||||||
( ( UBaseType_t ) configTIMER_TASK_PRIORITY ) | portPRIVILEGE_BIT,
|
uint32_t ulTimerTaskStackSize;
|
||||||
&xTimerTaskHandle );
|
|
||||||
|
vApplicationGetTimerTaskMemory( &pxTimerTaskTCBBuffer, &pxTimerTaskStackBuffer, &ulTimerTaskStackSize );
|
||||||
|
xTimerTaskHandle = xTaskCreateStatic( prvTimerTask,
|
||||||
|
configTIMER_SERVICE_TASK_NAME,
|
||||||
|
ulTimerTaskStackSize,
|
||||||
|
NULL,
|
||||||
|
( ( UBaseType_t ) configTIMER_TASK_PRIORITY ) | portPRIVILEGE_BIT,
|
||||||
|
pxTimerTaskStackBuffer,
|
||||||
|
pxTimerTaskTCBBuffer );
|
||||||
|
|
||||||
|
if( xTimerTaskHandle != NULL )
|
||||||
|
{
|
||||||
|
xReturn = pdPASS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else /* if ( configSUPPORT_STATIC_ALLOCATION == 1 ) */
|
||||||
|
{
|
||||||
|
xReturn = xTaskCreate( prvTimerTask,
|
||||||
|
configTIMER_SERVICE_TASK_NAME,
|
||||||
|
configTIMER_TASK_STACK_DEPTH,
|
||||||
|
NULL,
|
||||||
|
( ( UBaseType_t ) configTIMER_TASK_PRIORITY ) | portPRIVILEGE_BIT,
|
||||||
|
&xTimerTaskHandle );
|
||||||
|
}
|
||||||
|
#endif /* configSUPPORT_STATIC_ALLOCATION */
|
||||||
}
|
}
|
||||||
#endif /* configSUPPORT_STATIC_ALLOCATION */
|
#endif /* #if ( ( configNUMBER_OF_CORES > 1 ) && ( configUSE_CORE_AFFINITY == 1 ) ) */
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue