Uncrustified tasks.c

This commit is contained in:
Joseph Julicher 2021-05-19 08:38:58 -07:00
parent 87279a3dc7
commit 106e15ea6b

70
tasks.c
View file

@ -290,7 +290,6 @@ typedef struct tskTaskControlBlock /* The old naming convention is used to
#endif #endif
#if ( configUSE_NEWLIB_REENTRANT == 1 ) #if ( configUSE_NEWLIB_REENTRANT == 1 )
/* Allocate a Newlib reent structure that is specific to this task. /* Allocate a Newlib reent structure that is specific to this task.
* Note Newlib support has been included by popular demand, but is not * Note Newlib support has been included by popular demand, but is not
* used by the FreeRTOS maintainers themselves. FreeRTOS is not * used by the FreeRTOS maintainers themselves. FreeRTOS is not
@ -469,7 +468,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
/* /*
@ -761,7 +760,7 @@ static void prvYieldForTask( TCB_t * pxTCB,
{ {
if( xTaskPriority <= xLowestPriority ) if( xTaskPriority <= xLowestPriority )
{ {
#if( configNUM_CORES > 1 ) #if ( configNUM_CORES > 1 )
#if ( configUSE_CORE_AFFINITY == 1 ) #if ( configUSE_CORE_AFFINITY == 1 )
if( ( pxTCB->uxCoreAffinityMask & ( 1 << x ) ) != 0 ) if( ( pxTCB->uxCoreAffinityMask & ( 1 << x ) ) != 0 )
#endif #endif
@ -914,7 +913,7 @@ static void prvYieldForTask( TCB_t * pxTCB,
else if( pxTCB == pxCurrentTCBs[ xCoreID ] ) else if( pxTCB == pxCurrentTCBs[ xCoreID ] )
{ {
configASSERT( ( pxTCB->xTaskRunState == xCoreID ) || ( pxTCB->xTaskRunState == taskTASK_YIELDING ) ); configASSERT( ( pxTCB->xTaskRunState == xCoreID ) || ( pxTCB->xTaskRunState == taskTASK_YIELDING ) );
#if( configNUM_CORES > 1 ) #if ( configNUM_CORES > 1 )
#if ( configUSE_CORE_AFFINITY == 1 ) #if ( configUSE_CORE_AFFINITY == 1 )
if( ( pxTCB->uxCoreAffinityMask & ( 1 << xCoreID ) ) != 0 ) if( ( pxTCB->uxCoreAffinityMask & ( 1 << xCoreID ) ) != 0 )
#endif #endif
@ -1557,12 +1556,13 @@ 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;
} }
#if(configNUM_CORES > 1)
else if(pxTaskCode == prvMinimalIdleTask) #if ( configNUM_CORES > 1 )
else if( pxTaskCode == prvMinimalIdleTask )
{ {
pxNewTCB->xIsIdle = pdTRUE; pxNewTCB->xIsIdle = pdTRUE;
} }
@ -1617,11 +1617,12 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB )
if( pxCurrentTCBs[ xCoreID ] == NULL ) if( pxCurrentTCBs[ xCoreID ] == NULL )
{ {
pxNewTCB->xTaskRunState = xCoreID; pxNewTCB->xTaskRunState = xCoreID;
/* This section of code pins the idle tasks to cores. /* This section of code pins the idle tasks to cores.
#if ( configUSE_CORE_AFFINITY == 1 ) #if ( configUSE_CORE_AFFINITY == 1 )
{ * {
pxNewTCB->uxCoreAffinityMask = ( 1 << xCoreID ); * pxNewTCB->uxCoreAffinityMask = ( 1 << xCoreID );
} * }
#endif #endif
*/ */
pxCurrentTCBs[ xCoreID ] = pxNewTCB; pxCurrentTCBs[ xCoreID ] = pxNewTCB;
@ -1713,7 +1714,6 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB )
* no longer running. */ * no longer running. */
if( xTaskRunningOnCore != taskTASK_NOT_RUNNING ) if( xTaskRunningOnCore != taskTASK_NOT_RUNNING )
{ {
/* A running task is being deleted. This cannot complete within the /* A running task is being deleted. This cannot complete within the
* task itself, as a context switch to another task is required. * task itself, as a context switch to another task is required.
* Place the task in the termination list. The idle task will * Place the task in the termination list. The idle task will
@ -1755,7 +1755,6 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB )
xCoreID = portGET_CORE_ID(); xCoreID = portGET_CORE_ID();
if( xTaskRunningOnCore == xCoreID ) if( xTaskRunningOnCore == xCoreID )
{ {
configASSERT( uxSchedulerSuspended == 0 ); configASSERT( uxSchedulerSuspended == 0 );
@ -2232,7 +2231,7 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB )
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
#if ( configNUM_CORES > 1 ) #if ( configNUM_CORES > 1 )
#if ( configUSE_CORE_AFFINITY == 1 ) #if ( configUSE_CORE_AFFINITY == 1 )
void vTaskCoreAffinitySet( const TaskHandle_t xTask, void vTaskCoreAffinitySet( const TaskHandle_t xTask,
UBaseType_t uxCoreAffinityMask ) UBaseType_t uxCoreAffinityMask )
@ -2262,12 +2261,12 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB )
taskEXIT_CRITICAL(); taskEXIT_CRITICAL();
} }
#endif /* configUSE_CORE_AFFINITY */ #endif /* configUSE_CORE_AFFINITY */
#endif #endif /* if ( configNUM_CORES > 1 ) */
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
#if ( configNUM_CORES > 1 ) #if ( configNUM_CORES > 1 )
#if ( configUSE_CORE_AFFINITY == 1 ) #if ( configUSE_CORE_AFFINITY == 1 )
UBaseType_t vTaskCoreAffinityGet( const TaskHandle_t xTask ) UBaseType_t vTaskCoreAffinityGet( const TaskHandle_t xTask )
{ {
@ -2284,8 +2283,8 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB )
return uxCoreAffinityMask; return uxCoreAffinityMask;
} }
#endif /* configUSE_CORE_AFFINITY */ #endif /* configUSE_CORE_AFFINITY */
#endif #endif /* if ( configNUM_CORES > 1 ) */
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
@ -2688,7 +2687,7 @@ static BaseType_t prvCreateIdleTasks( void )
#if ( configSUPPORT_STATIC_ALLOCATION == 1 ) #if ( configSUPPORT_STATIC_ALLOCATION == 1 )
{ {
if(xCoreID == 0) if( xCoreID == 0 )
{ {
StaticTask_t * pxIdleTaskTCBBuffer = NULL; StaticTask_t * pxIdleTaskTCBBuffer = NULL;
StackType_t * pxIdleTaskStackBuffer = NULL; StackType_t * pxIdleTaskStackBuffer = NULL;
@ -2705,21 +2704,23 @@ 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
{ {
static StaticTask_t xIdleTCBBuffers[configNUM_CORES-1]; static StaticTask_t xIdleTCBBuffers[ configNUM_CORES - 1 ];
static StackType_t xIdleTaskStackBuffers[configNUM_CORES-1][configMINIMAL_STACK_SIZE]; static StackType_t xIdleTaskStackBuffers[ configNUM_CORES - 1 ][ configMINIMAL_STACK_SIZE ];
xIdleTaskHandle[ xCoreID ] = xTaskCreateStatic( prvMinimalIdleTask, xIdleTaskHandle[ xCoreID ] = xTaskCreateStatic( prvMinimalIdleTask,
cIdleName, cIdleName,
configMINIMAL_STACK_SIZE, configMINIMAL_STACK_SIZE,
( void * ) NULL, /*lint !e961. The cast is not redundant for all compilers. */ ( void * ) NULL, /*lint !e961. The cast is not redundant for all compilers. */
portPRIVILEGE_BIT, /* In effect ( tskIDLE_PRIORITY | portPRIVILEGE_BIT ), but tskIDLE_PRIORITY is zero. */ portPRIVILEGE_BIT, /* In effect ( tskIDLE_PRIORITY | portPRIVILEGE_BIT ), but tskIDLE_PRIORITY is zero. */
xIdleTaskStackBuffers[xCoreID-1], xIdleTaskStackBuffers[ xCoreID - 1 ],
&xIdleTCBBuffers[xCoreID-1] ); /*lint !e961 MISRA exception, justified as it is not a redundant explicit cast to all supported compilers. */ &xIdleTCBBuffers[ xCoreID - 1 ] ); /*lint !e961 MISRA exception, justified as it is not a redundant explicit cast to all supported compilers. */
} }
#endif #endif /* if ( configNUM_CORES > 1 ) */
if( xIdleTaskHandle[ xCoreID ] != NULL ) if( xIdleTaskHandle[ xCoreID ] != NULL )
{ {
xReturn = pdPASS; xReturn = pdPASS;
@ -2731,7 +2732,7 @@ static BaseType_t prvCreateIdleTasks( void )
} }
#else /* if ( configSUPPORT_STATIC_ALLOCATION == 1 ) */ #else /* if ( configSUPPORT_STATIC_ALLOCATION == 1 ) */
{ {
if(xCoreID == 0) if( xCoreID == 0 )
{ {
/* The Idle task is being created using dynamically allocated RAM. */ /* The Idle task is being created using dynamically allocated RAM. */
xReturn = xTaskCreate( prvIdleTask, xReturn = xTaskCreate( prvIdleTask,
@ -2741,7 +2742,8 @@ static BaseType_t prvCreateIdleTasks( void )
portPRIVILEGE_BIT, /* In effect ( tskIDLE_PRIORITY | portPRIVILEGE_BIT ), but tskIDLE_PRIORITY is zero. */ portPRIVILEGE_BIT, /* In effect ( tskIDLE_PRIORITY | portPRIVILEGE_BIT ), but tskIDLE_PRIORITY is zero. */
&xIdleTaskHandle[ xCoreID ] ); /*lint !e961 MISRA exception, justified as it is not a redundant explicit cast to all supported compilers. */ &xIdleTaskHandle[ xCoreID ] ); /*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
{ {
xReturn = xTaskCreate( prvMinimalIdleTask, xReturn = xTaskCreate( prvMinimalIdleTask,
@ -2755,6 +2757,7 @@ static BaseType_t prvCreateIdleTasks( void )
} }
#endif /* configSUPPORT_STATIC_ALLOCATION */ #endif /* configSUPPORT_STATIC_ALLOCATION */
} }
return xReturn; return xReturn;
} }
@ -4225,10 +4228,10 @@ void vTaskMissedYield( void )
* *
* @todo additional conditional compiles to remove this function. * @todo additional conditional compiles to remove this function.
*/ */
#if (configNUM_CORES > 1) #if ( configNUM_CORES > 1 )
static portTASK_FUNCTION( prvMinimalIdleTask, pvParameters ) static portTASK_FUNCTION( prvMinimalIdleTask, pvParameters )
{ {
for(;;) for( ; ; )
{ {
#if ( configUSE_PREEMPTION == 0 ) #if ( configUSE_PREEMPTION == 0 )
{ {
@ -4263,8 +4266,9 @@ static portTASK_FUNCTION( prvMinimalIdleTask, pvParameters )
} }
#endif /* ( ( configUSE_PREEMPTION == 1 ) && ( configIDLE_SHOULD_YIELD == 1 ) ) */ #endif /* ( ( configUSE_PREEMPTION == 1 ) && ( configIDLE_SHOULD_YIELD == 1 ) ) */
} }
} }
#endif #endif /* if ( configNUM_CORES > 1 ) */
/* /*
* ----------------------------------------------------------- * -----------------------------------------------------------
* The Idle task. * The Idle task.