]> git.sur5r.net Git - freertos/commitdiff
Ensure vTaskGetInfo() sets the sate of the currently running task to eRunning - previ...
authorrtel <rtel@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Mon, 27 Mar 2017 20:31:03 +0000 (20:31 +0000)
committerrtel <rtel@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Mon, 27 Mar 2017 20:31:03 +0000 (20:31 +0000)
git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@2491 1d2547de-c912-0410-9cb9-b8ca96c0e9e2

FreeRTOS/Source/tasks.c

index 76abb9e7cac283a0d4496d2e4c1316911e6e4960..460f4bf3cd899fade3708b011cf7adbf4a77a925 100644 (file)
@@ -3555,25 +3555,6 @@ static void prvCheckTasksWaitingTermination( void )
                pxTaskStatus->pxStackBase = pxTCB->pxStack;\r
                pxTaskStatus->xTaskNumber = pxTCB->uxTCBNumber;\r
 \r
-               #if ( INCLUDE_vTaskSuspend == 1 )\r
-               {\r
-                       /* If the task is in the suspended list then there is a chance it is\r
-                       actually just blocked indefinitely - so really it should be reported as\r
-                       being in the Blocked state. */\r
-                       if( pxTaskStatus->eCurrentState == eSuspended )\r
-                       {\r
-                               vTaskSuspendAll();\r
-                               {\r
-                                       if( listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) ) != NULL )\r
-                                       {\r
-                                               pxTaskStatus->eCurrentState = eBlocked;\r
-                                       }\r
-                               }\r
-                               ( void ) xTaskResumeAll();\r
-                       }\r
-               }\r
-               #endif /* INCLUDE_vTaskSuspend */\r
-\r
                #if ( configUSE_MUTEXES == 1 )\r
                {\r
                        pxTaskStatus->uxBasePriority = pxTCB->uxBasePriority;\r
@@ -3594,12 +3575,38 @@ static void prvCheckTasksWaitingTermination( void )
                }\r
                #endif\r
 \r
-               /* Obtaining the task state is a little fiddly, so is only done if the value\r
-               of eState passed into this function is eInvalid - otherwise the state is\r
-               just set to whatever is passed in. */\r
+               /* Obtaining the task state is a little fiddly, so is only done if the\r
+               value of eState passed into this function is eInvalid - otherwise the\r
+               state is just set to whatever is passed in. */\r
                if( eState != eInvalid )\r
                {\r
-                       pxTaskStatus->eCurrentState = eState;\r
+                       if( pxTCB == pxCurrentTCB )\r
+                       {\r
+                               pxTaskStatus->eCurrentState = eRunning;\r
+                       }\r
+                       else\r
+                       {\r
+                               pxTaskStatus->eCurrentState = eState;\r
+\r
+                               #if ( INCLUDE_vTaskSuspend == 1 )\r
+                               {\r
+                                       /* If the task is in the suspended list then there is a\r
+                                       chance it is actually just blocked indefinitely - so really\r
+                                       it should be reported as being in the Blocked state. */\r
+                                       if( eState == eSuspended )\r
+                                       {\r
+                                               vTaskSuspendAll();\r
+                                               {\r
+                                                       if( listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) ) != NULL )\r
+                                                       {\r
+                                                               pxTaskStatus->eCurrentState = eBlocked;\r
+                                                       }\r
+                                               }\r
+                                               ( void ) xTaskResumeAll();\r
+                                       }\r
+                               }\r
+                               #endif /* INCLUDE_vTaskSuspend */\r
+                       }\r
                }\r
                else\r
                {\r