adding a minimal idle hook to the SMP port (#329)

* adjusting the kernel checks repo

* Added a minimal idle hook for all idle tasks
This commit is contained in:
Joseph Julicher 2021-05-19 16:19:57 -07:00 committed by GitHub
parent 0c1381311b
commit b515641e0a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 174 additions and 139 deletions

View file

@ -21,7 +21,7 @@ jobs:
uses: actions/checkout@v2 uses: actions/checkout@v2
with: with:
repository: FreeRTOS/FreeRTOS repository: FreeRTOS/FreeRTOS
ref: master ref: smp
path: tools path: tools
# Checkout user pull request changes # Checkout user pull request changes

51
tasks.c
View file

@ -467,7 +467,7 @@ static void prvInitialiseTaskLists( void ) PRIVILEGED_FUNCTION;
*/ */
static portTASK_FUNCTION_PROTO( prvIdleTask, pvParameters ) PRIVILEGED_FUNCTION; static portTASK_FUNCTION_PROTO( prvIdleTask, pvParameters ) PRIVILEGED_FUNCTION;
#if ( configNUM_CORES > 1 ) #if ( configNUM_CORES > 1 )
static portTASK_FUNCTION_PROTO( prvMinimalIdleTask, pvParameters ) PRIVILEGED_FUNCTION; static portTASK_FUNCTION_PROTO( prvMinimalIdleTask, pvParameters ) PRIVILEGED_FUNCTION;
#endif #endif
/* /*
@ -1000,8 +1000,7 @@ static void prvYieldForTask( TCB_t * pxTCB,
} }
else else
{ {
/* The ready task that was removed from this core is excluded from it. /* The ready task that was removed from this core is excluded from it. */
* @todo See if we can schedule it on any of the cores where it is not excluded from. */
} }
uxCoreMap &= ( ( 1 << configNUM_CORES ) - 1 ); uxCoreMap &= ( ( 1 << configNUM_CORES ) - 1 );
@ -1555,7 +1554,7 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
pxNewTCB->xTaskRunState = taskTASK_NOT_RUNNING; pxNewTCB->xTaskRunState = taskTASK_NOT_RUNNING;
/* Is this an idle task? */ /* Is this an idle task? */
if(pxTaskCode == prvIdleTask) if( pxTaskCode == prvIdleTask )
{ {
pxNewTCB->xIsIdle = pdTRUE; pxNewTCB->xIsIdle = pdTRUE;
} }
@ -2242,7 +2241,7 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB )
{ {
xCoreID = ( BaseType_t ) pxTCB->xTaskRunState; xCoreID = ( BaseType_t ) pxTCB->xTaskRunState;
if( ( uxCoreAffinityMask & ( 1 << xCoreID ) ) != 0 ) if( ( uxCoreAffinityMask & ( 1 << xCoreID ) ) == 0 )
{ {
prvYieldCore( xCoreID ); prvYieldCore( xCoreID );
} }
@ -2695,6 +2694,7 @@ static BaseType_t prvCreateIdleTasks( void )
pxIdleTaskStackBuffer, pxIdleTaskStackBuffer,
pxIdleTaskTCBBuffer ); /*lint !e961 MISRA exception, justified as it is not a redundant explicit cast to all supported compilers. */ pxIdleTaskTCBBuffer ); /*lint !e961 MISRA exception, justified as it is not a redundant explicit cast to all supported compilers. */
} }
#if ( configNUM_CORES > 1 ) #if ( configNUM_CORES > 1 )
else else
{ {
@ -2747,6 +2747,7 @@ static BaseType_t prvCreateIdleTasks( void )
} }
#endif /* configSUPPORT_STATIC_ALLOCATION */ #endif /* configSUPPORT_STATIC_ALLOCATION */
} }
return xReturn; return xReturn;
} }
@ -4219,9 +4220,10 @@ void vTaskMissedYield( void )
*/ */
#if ( configNUM_CORES > 1 ) #if ( configNUM_CORES > 1 )
static portTASK_FUNCTION( prvMinimalIdleTask, pvParameters ) static portTASK_FUNCTION( prvMinimalIdleTask, pvParameters )
{ {
taskYIELD(); taskYIELD();
for( ; ; ) for( ; ; )
{ {
#if ( configUSE_PREEMPTION == 0 ) #if ( configUSE_PREEMPTION == 0 )
@ -4256,8 +4258,24 @@ static portTASK_FUNCTION( prvMinimalIdleTask, pvParameters )
} }
} }
#endif /* ( ( configUSE_PREEMPTION == 1 ) && ( configIDLE_SHOULD_YIELD == 1 ) ) */ #endif /* ( ( configUSE_PREEMPTION == 1 ) && ( configIDLE_SHOULD_YIELD == 1 ) ) */
#if ( configUSE_MINIMAL_IDLE_HOOK == 1 )
{
extern void vApplicationMinimalIdleHook( void );
/* Call the user defined function from within the idle task. This
* allows the application designer to add background functionality
* without the overhead of a separate task.
*
* This hook is intended to manage core activity such as disabling cores that go idle.
*
* NOTE: vApplicationMinimalIdleHook() MUST NOT, UNDER ANY CIRCUMSTANCES,
* CALL A FUNCTION THAT MIGHT BLOCK. */
vApplicationMinimalIdleHook();
}
#endif /* configUSE_MINIMAL_IDLE_HOOK */
}
} }
}
#endif /* if ( configNUM_CORES > 1 ) */ #endif /* if ( configNUM_CORES > 1 ) */
/* /*
@ -4330,6 +4348,7 @@ static portTASK_FUNCTION( prvIdleTask, pvParameters )
/* Call the user defined function from within the idle task. This /* Call the user defined function from within the idle task. This
* allows the application designer to add background functionality * allows the application designer to add background functionality
* without the overhead of a separate task. * without the overhead of a separate task.
*
* NOTE: vApplicationIdleHook() MUST NOT, UNDER ANY CIRCUMSTANCES, * NOTE: vApplicationIdleHook() MUST NOT, UNDER ANY CIRCUMSTANCES,
* CALL A FUNCTION THAT MIGHT BLOCK. */ * CALL A FUNCTION THAT MIGHT BLOCK. */
vApplicationIdleHook(); vApplicationIdleHook();
@ -4385,6 +4404,22 @@ static portTASK_FUNCTION( prvIdleTask, pvParameters )
} }
} }
#endif /* configUSE_TICKLESS_IDLE */ #endif /* configUSE_TICKLESS_IDLE */
#if ( configUSE_MINIMAL_IDLE_HOOK == 1 )
{
extern void vApplicationMinimalIdleHook( void );
/* Call the user defined function from within the idle task. This
* allows the application designer to add background functionality
* without the overhead of a separate task.
*
* This hook is intended to manage core activity such as disabling cores that go idle.
*
* NOTE: vApplicationMinimalIdleHook() MUST NOT, UNDER ANY CIRCUMSTANCES,
* CALL A FUNCTION THAT MIGHT BLOCK. */
vApplicationMinimalIdleHook();
}
#endif /* configUSE_MINIMAL_IDLE_HOOK */
} }
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/