mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-04-19 21:11:57 -04:00
Update task running state type and related macros (#770)
* Remove unnecessary type TaskRunning_t * Rename taskTASK_YIELD to taskTASK_SCHEDULED_TO_YIELD --------- Co-authored-by: Soren Ptak <ptaksoren@gmail.com>
This commit is contained in:
parent
53229b1537
commit
c93d3865f7
32
tasks.c
32
tasks.c
|
@ -259,14 +259,11 @@
|
||||||
#define taskEVENT_LIST_ITEM_VALUE_IN_USE 0x8000000000000000ULL
|
#define taskEVENT_LIST_ITEM_VALUE_IN_USE 0x8000000000000000ULL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Task state. */
|
|
||||||
typedef BaseType_t TaskRunning_t;
|
|
||||||
|
|
||||||
/* Indicates that the task is not actively running on any core. */
|
/* Indicates that the task is not actively running on any core. */
|
||||||
#define taskTASK_NOT_RUNNING ( TaskRunning_t ) ( -1 )
|
#define taskTASK_NOT_RUNNING ( ( BaseType_t ) ( -1 ) )
|
||||||
|
|
||||||
/* Indicates that the task is actively running but scheduled to yield. */
|
/* Indicates that the task is actively running but scheduled to yield. */
|
||||||
#define taskTASK_YIELDING ( TaskRunning_t ) ( -2 )
|
#define taskTASK_SCHEDULED_TO_YIELD ( ( BaseType_t ) ( -2 ) )
|
||||||
|
|
||||||
/* Returns pdTRUE if the task is actively running and not scheduled to yield. */
|
/* Returns pdTRUE if the task is actively running and not scheduled to yield. */
|
||||||
#if ( configNUMBER_OF_CORES == 1 )
|
#if ( configNUMBER_OF_CORES == 1 )
|
||||||
|
@ -313,7 +310,7 @@ typedef struct tskTaskControlBlock /* The old naming convention is used to
|
||||||
UBaseType_t uxPriority; /**< The priority of the task. 0 is the lowest priority. */
|
UBaseType_t uxPriority; /**< The priority of the task. 0 is the lowest priority. */
|
||||||
StackType_t * pxStack; /**< Points to the start of the stack. */
|
StackType_t * pxStack; /**< Points to the start of the stack. */
|
||||||
#if ( configNUMBER_OF_CORES > 1 )
|
#if ( configNUMBER_OF_CORES > 1 )
|
||||||
volatile TaskRunning_t xTaskRunState; /**< Used to identify the core the task is running on, if the task is running. Otherwise, identifies the task's state - not running or yielding. */
|
volatile BaseType_t xTaskRunState; /**< Used to identify the core the task is running on, if the task is running. Otherwise, identifies the task's state - not running or yielding. */
|
||||||
UBaseType_t uxTaskAttributes; /**< Task's attributes - currently used to identify the idle tasks. */
|
UBaseType_t uxTaskAttributes; /**< Task's attributes - currently used to identify the idle tasks. */
|
||||||
#endif
|
#endif
|
||||||
char pcTaskName[ configMAX_TASK_NAME_LEN ]; /**< Descriptive name given to the task when created. Facilitates debugging only. */ /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
|
char pcTaskName[ configMAX_TASK_NAME_LEN ]; /**< Descriptive name given to the task when created. Facilitates debugging only. */ /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
|
||||||
|
@ -700,7 +697,7 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB ) PRIVILEGED_FUNCTION;
|
||||||
* so this is safe. */
|
* so this is safe. */
|
||||||
pxThisTCB = pxCurrentTCBs[ portGET_CORE_ID() ];
|
pxThisTCB = pxCurrentTCBs[ portGET_CORE_ID() ];
|
||||||
|
|
||||||
while( pxThisTCB->xTaskRunState == taskTASK_YIELDING )
|
while( pxThisTCB->xTaskRunState == taskTASK_SCHEDULED_TO_YIELD )
|
||||||
{
|
{
|
||||||
/* We are only here if we just entered a critical section
|
/* We are only here if we just entered a critical section
|
||||||
* or if we just suspended the scheduler, and another task
|
* or if we just suspended the scheduler, and another task
|
||||||
|
@ -725,16 +722,15 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB ) PRIVILEGED_FUNCTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
portRELEASE_TASK_LOCK();
|
portRELEASE_TASK_LOCK();
|
||||||
|
|
||||||
portMEMORY_BARRIER();
|
portMEMORY_BARRIER();
|
||||||
configASSERT( pxThisTCB->xTaskRunState == taskTASK_YIELDING );
|
configASSERT( pxThisTCB->xTaskRunState == taskTASK_SCHEDULED_TO_YIELD );
|
||||||
|
|
||||||
portENABLE_INTERRUPTS();
|
portENABLE_INTERRUPTS();
|
||||||
|
|
||||||
/* Enabling interrupts should cause this core to immediately
|
/* Enabling interrupts should cause this core to immediately
|
||||||
* service the pending interrupt and yield. If the run state is still
|
* service the pending interrupt and yield. If the run state is still
|
||||||
* yielding here then that is a problem. */
|
* yielding here then that is a problem. */
|
||||||
configASSERT( pxThisTCB->xTaskRunState != taskTASK_YIELDING );
|
configASSERT( pxThisTCB->xTaskRunState != taskTASK_SCHEDULED_TO_YIELD );
|
||||||
|
|
||||||
portDISABLE_INTERRUPTS();
|
portDISABLE_INTERRUPTS();
|
||||||
portGET_TASK_LOCK();
|
portGET_TASK_LOCK();
|
||||||
|
@ -762,7 +758,7 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB ) PRIVILEGED_FUNCTION;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if( pxCurrentTCBs[ xCoreID ]->xTaskRunState != taskTASK_YIELDING )
|
if( pxCurrentTCBs[ xCoreID ]->xTaskRunState != taskTASK_SCHEDULED_TO_YIELD )
|
||||||
{
|
{
|
||||||
if( xCoreID == ( BaseType_t ) portGET_CORE_ID() )
|
if( xCoreID == ( BaseType_t ) portGET_CORE_ID() )
|
||||||
{
|
{
|
||||||
|
@ -771,7 +767,7 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB ) PRIVILEGED_FUNCTION;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
portYIELD_CORE( xCoreID );
|
portYIELD_CORE( xCoreID );
|
||||||
pxCurrentTCBs[ xCoreID ]->xTaskRunState = taskTASK_YIELDING;
|
pxCurrentTCBs[ xCoreID ]->xTaskRunState = taskTASK_SCHEDULED_TO_YIELD;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -982,21 +978,21 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB ) PRIVILEGED_FUNCTION;
|
||||||
#if ( configUSE_CORE_AFFINITY == 1 )
|
#if ( configUSE_CORE_AFFINITY == 1 )
|
||||||
pxPreviousTCB = pxCurrentTCBs[ xCoreID ];
|
pxPreviousTCB = pxCurrentTCBs[ xCoreID ];
|
||||||
#endif
|
#endif
|
||||||
pxTCB->xTaskRunState = ( TaskRunning_t ) xCoreID;
|
pxTCB->xTaskRunState = xCoreID;
|
||||||
pxCurrentTCBs[ xCoreID ] = pxTCB;
|
pxCurrentTCBs[ xCoreID ] = pxTCB;
|
||||||
xTaskScheduled = pdTRUE;
|
xTaskScheduled = pdTRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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_SCHEDULED_TO_YIELD ) );
|
||||||
|
|
||||||
#if ( configUSE_CORE_AFFINITY == 1 )
|
#if ( configUSE_CORE_AFFINITY == 1 )
|
||||||
if( ( pxTCB->uxCoreAffinityMask & ( ( UBaseType_t ) 1U << ( UBaseType_t ) xCoreID ) ) != 0U )
|
if( ( pxTCB->uxCoreAffinityMask & ( ( UBaseType_t ) 1U << ( UBaseType_t ) xCoreID ) ) != 0U )
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
/* The task is already running on this core, mark it as scheduled. */
|
/* The task is already running on this core, mark it as scheduled. */
|
||||||
pxTCB->xTaskRunState = ( TaskRunning_t ) xCoreID;
|
pxTCB->xTaskRunState = xCoreID;
|
||||||
xTaskScheduled = pdTRUE;
|
xTaskScheduled = pdTRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1999,7 +1995,7 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
|
||||||
/* Force a reschedule if the task that has just been deleted was running. */
|
/* Force a reschedule if the task that has just been deleted was running. */
|
||||||
if( ( xSchedulerRunning != pdFALSE ) && ( taskTASK_IS_RUNNING( pxTCB ) == pdTRUE ) )
|
if( ( xSchedulerRunning != pdFALSE ) && ( taskTASK_IS_RUNNING( pxTCB ) == pdTRUE ) )
|
||||||
{
|
{
|
||||||
if( pxTCB->xTaskRunState == ( TaskRunning_t ) portGET_CORE_ID() )
|
if( pxTCB->xTaskRunState == ( BaseType_t ) portGET_CORE_ID() )
|
||||||
{
|
{
|
||||||
configASSERT( uxSchedulerSuspended == 0 );
|
configASSERT( uxSchedulerSuspended == 0 );
|
||||||
vTaskYieldWithinAPI();
|
vTaskYieldWithinAPI();
|
||||||
|
@ -2704,7 +2700,7 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
|
||||||
TCB_t * pxTCB;
|
TCB_t * pxTCB;
|
||||||
|
|
||||||
#if ( configNUMBER_OF_CORES > 1 )
|
#if ( configNUMBER_OF_CORES > 1 )
|
||||||
TaskRunning_t xTaskRunningOnCore;
|
BaseType_t xTaskRunningOnCore;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
taskENTER_CRITICAL();
|
taskENTER_CRITICAL();
|
||||||
|
@ -2827,7 +2823,7 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
|
||||||
{
|
{
|
||||||
if( xSchedulerRunning != pdFALSE )
|
if( xSchedulerRunning != pdFALSE )
|
||||||
{
|
{
|
||||||
if( xTaskRunningOnCore == ( TaskRunning_t ) portGET_CORE_ID() )
|
if( xTaskRunningOnCore == ( BaseType_t ) portGET_CORE_ID() )
|
||||||
{
|
{
|
||||||
/* The current task has just been suspended. */
|
/* The current task has just been suspended. */
|
||||||
configASSERT( uxSchedulerSuspended == 0 );
|
configASSERT( uxSchedulerSuspended == 0 );
|
||||||
|
|
Loading…
Reference in a new issue