Skip to content

Commit

Permalink
Distinguish waiting for notify status from suspend status (#865)
Browse files Browse the repository at this point in the history
* Fix prvTaskIsTaskSuspended.

Just like eTaskGetState, distinguish waiting for notify from suspend.

* Fix vTaskGetInfo.

Just like eTaskGetState, distinguish block state (waiting on notification)
from suspend state.

* Add missing definition of variable x.

* Fix formatting syntax.

---------

Co-authored-by: Rahul Kar <[email protected]>
Co-authored-by: Tony Josi <[email protected]>
  • Loading branch information
3 people authored Nov 7, 2023
1 parent 8ede50c commit 0640b2e
Showing 1 changed file with 44 additions and 2 deletions.
46 changes: 44 additions & 2 deletions tasks.c
Original file line number Diff line number Diff line change
Expand Up @@ -3284,10 +3284,34 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
if( listIS_CONTAINED_WITHIN( &xPendingReadyList, &( pxTCB->xEventListItem ) ) == pdFALSE )
{
/* Is it in the suspended list because it is in the Suspended
* state, or because is is blocked with no timeout? */
* state, or because it is blocked with no timeout? */
if( listIS_CONTAINED_WITHIN( NULL, &( pxTCB->xEventListItem ) ) != pdFALSE ) /*lint !e961. The cast is only redundant when NULL is used. */
{
xReturn = pdTRUE;
#if ( configUSE_TASK_NOTIFICATIONS == 1 )
{
BaseType_t x;

/* The task does not appear on the event list item of
* and of the RTOS objects, but could still be in the
* blocked state if it is waiting on its notification
* rather than waiting on an object. If not, is
* suspended. */
xReturn = pdTRUE;

for( x = ( BaseType_t ) 0; x < ( BaseType_t ) configTASK_NOTIFICATION_ARRAY_ENTRIES; x++ )
{
if( pxTCB->ucNotifyState[ x ] == taskWAITING_NOTIFICATION )
{
xReturn = pdFALSE;
break;
}
}
}
#else /* if ( configUSE_TASK_NOTIFICATIONS == 1 ) */
{
xReturn = pdTRUE;
}
#endif /* if ( configUSE_TASK_NOTIFICATIONS == 1 ) */
}
else
{
Expand Down Expand Up @@ -6131,6 +6155,24 @@ static void prvCheckTasksWaitingTermination( void )
{
pxTaskStatus->eCurrentState = eBlocked;
}
else
{
BaseType_t x;

/* The task does not appear on the event list item of
* and of the RTOS objects, but could still be in the
* blocked state if it is waiting on its notification
* rather than waiting on an object. If not, is
* suspended. */
for( x = ( BaseType_t ) 0; x < ( BaseType_t ) configTASK_NOTIFICATION_ARRAY_ENTRIES; x++ )
{
if( pxTCB->ucNotifyState[ x ] == taskWAITING_NOTIFICATION )
{
pxTaskStatus->eCurrentState = eBlocked;
break;
}
}
}
}
( void ) xTaskResumeAll();
}
Expand Down

0 comments on commit 0640b2e

Please sign in to comment.