Skip to content

Commit

Permalink
Add macro taskTASK_IS_RUNNING_OR_YIELDING
Browse files Browse the repository at this point in the history
* Add taskTASK_IS_RUNNING_OR_YIELDING macro to align single core and SMP
  • Loading branch information
chinglee-iot committed Sep 5, 2023
1 parent 231278e commit 8e898b7
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions tasks.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,11 @@ typedef BaseType_t TaskRunning_t;

/* Returns pdTRUE if the task is actively running and not scheduled to yield. */
#if ( configNUMBER_OF_CORES == 1 )
#define taskTASK_IS_RUNNING( pxTCB ) ( ( ( pxTCB ) == pxCurrentTCB ) ? ( pdTRUE ) : ( pdFALSE ) )
#define taskTASK_IS_RUNNING( pxTCB ) ( ( ( pxTCB ) == pxCurrentTCB ) ? ( pdTRUE ) : ( pdFALSE ) )
#define taskTASK_IS_RUNNING_OR_YIELDING( pxTCB ) ( ( ( pxTCB ) == pxCurrentTCB ) ? ( pdTRUE ) : ( pdFALSE ) )
#else
#define taskTASK_IS_RUNNING( pxTCB ) ( ( ( ( pxTCB )->xTaskRunState >= ( BaseType_t ) 0 ) && ( ( pxTCB )->xTaskRunState < ( BaseType_t ) configNUMBER_OF_CORES ) ) ? ( pdTRUE ) : ( pdFALSE ) )
#define taskTASK_IS_RUNNING( pxTCB ) ( ( ( ( pxTCB )->xTaskRunState >= ( BaseType_t ) 0 ) && ( ( pxTCB )->xTaskRunState < ( BaseType_t ) configNUMBER_OF_CORES ) ) ? ( pdTRUE ) : ( pdFALSE ) )
#define taskTASK_IS_RUNNING_OR_YIELDING( pxTCB ) ( ( ( pxTCB )->xTaskRunState != taskTASK_NOT_RUNNING ) ? ( pdTRUE ) : ( pdFALSE ) )
#endif

/* Indicates that the task is an Idle task. */
Expand Down Expand Up @@ -1919,11 +1921,7 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
/* If the task is running (or yielding), we must add it to the
* termination list so that an idle task can delete it when it is
* no longer running. */
#if ( configNUMBER_OF_CORES == 1 )
if( pxTCB == pxCurrentTCB )
#else
if( pxTCB->xTaskRunState != taskTASK_NOT_RUNNING )
#endif
if( taskTASK_IS_RUNNING_OR_YIELDING( pxTCB ) != pdFALSE )
{
/* A running task is being deleted. This cannot complete within the
* task itself, as a context switch to another task is required.
Expand Down

0 comments on commit 8e898b7

Please sign in to comment.