Skip to content

Commit 8e898b7

Browse files
committed
Add macro taskTASK_IS_RUNNING_OR_YIELDING
* Add taskTASK_IS_RUNNING_OR_YIELDING macro to align single core and SMP
1 parent 231278e commit 8e898b7

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

tasks.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,11 @@ typedef BaseType_t TaskRunning_t;
270270

271271
/* Returns pdTRUE if the task is actively running and not scheduled to yield. */
272272
#if ( configNUMBER_OF_CORES == 1 )
273-
#define taskTASK_IS_RUNNING( pxTCB ) ( ( ( pxTCB ) == pxCurrentTCB ) ? ( pdTRUE ) : ( pdFALSE ) )
273+
#define taskTASK_IS_RUNNING( pxTCB ) ( ( ( pxTCB ) == pxCurrentTCB ) ? ( pdTRUE ) : ( pdFALSE ) )
274+
#define taskTASK_IS_RUNNING_OR_YIELDING( pxTCB ) ( ( ( pxTCB ) == pxCurrentTCB ) ? ( pdTRUE ) : ( pdFALSE ) )
274275
#else
275-
#define taskTASK_IS_RUNNING( pxTCB ) ( ( ( ( pxTCB )->xTaskRunState >= ( BaseType_t ) 0 ) && ( ( pxTCB )->xTaskRunState < ( BaseType_t ) configNUMBER_OF_CORES ) ) ? ( pdTRUE ) : ( pdFALSE ) )
276+
#define taskTASK_IS_RUNNING( pxTCB ) ( ( ( ( pxTCB )->xTaskRunState >= ( BaseType_t ) 0 ) && ( ( pxTCB )->xTaskRunState < ( BaseType_t ) configNUMBER_OF_CORES ) ) ? ( pdTRUE ) : ( pdFALSE ) )
277+
#define taskTASK_IS_RUNNING_OR_YIELDING( pxTCB ) ( ( ( pxTCB )->xTaskRunState != taskTASK_NOT_RUNNING ) ? ( pdTRUE ) : ( pdFALSE ) )
276278
#endif
277279

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

0 commit comments

Comments
 (0)