Fix eTaskGetState for pending ready tasks (#679)

This commit fixes eTaskGetState so that eReady is returned for pending ready
tasks.

Co-authored-by: Darian Leung <darian@espressif.com>
This commit is contained in:
Gaurav-Aggarwal-AWS 2023-05-25 16:33:10 +05:30 committed by GitHub
parent 97434a4e0c
commit 953c1ee6cb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

11
tasks.c
View file

@ -1351,6 +1351,7 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB )
{ {
eTaskState eReturn; eTaskState eReturn;
List_t const * pxStateList; List_t const * pxStateList;
List_t const * pxEventList;
List_t const * pxDelayedList; List_t const * pxDelayedList;
List_t const * pxOverflowedDelayedList; List_t const * pxOverflowedDelayedList;
const TCB_t * const pxTCB = xTask; const TCB_t * const pxTCB = xTask;
@ -1367,12 +1368,20 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB )
taskENTER_CRITICAL(); taskENTER_CRITICAL();
{ {
pxStateList = listLIST_ITEM_CONTAINER( &( pxTCB->xStateListItem ) ); pxStateList = listLIST_ITEM_CONTAINER( &( pxTCB->xStateListItem ) );
pxEventList = listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) );
pxDelayedList = pxDelayedTaskList; pxDelayedList = pxDelayedTaskList;
pxOverflowedDelayedList = pxOverflowDelayedTaskList; pxOverflowedDelayedList = pxOverflowDelayedTaskList;
} }
taskEXIT_CRITICAL(); taskEXIT_CRITICAL();
if( ( pxStateList == pxDelayedList ) || ( pxStateList == pxOverflowedDelayedList ) ) if( pxEventList == &xPendingReadyList )
{
/* The task has been placed on the pending ready list, so its
* state is eReady regardless of what list the task's state list
* item is currently placed on. */
eReturn = eReady;
}
else if( ( pxStateList == pxDelayedList ) || ( pxStateList == pxOverflowedDelayedList ) )
{ {
/* The task being queried is referenced from one of the Blocked /* The task being queried is referenced from one of the Blocked
* lists. */ * lists. */