]> git.sur5r.net Git - freertos/commitdiff
Update to FreeRTOS V6.1.0 release candidate. V6.1.0
authorrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Thu, 23 Sep 2010 18:07:41 +0000 (18:07 +0000)
committerrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Thu, 23 Sep 2010 18:07:41 +0000 (18:07 +0000)
git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@1135 1d2547de-c912-0410-9cb9-b8ca96c0e9e2

Source/tasks.c

index fafd9ceb72d15370ed96497d2c2b22042ec22e93..7b7d6413696112b1f687baa5acdcb74c216ba94f 100644 (file)
@@ -460,15 +460,19 @@ tskTCB * pxNewTCB;
                portENTER_CRITICAL();\r
                {\r
                        uxCurrentNumberOfTasks++;\r
-                       if( uxCurrentNumberOfTasks == ( unsigned portBASE_TYPE ) 1 )\r
+                       if( pxCurrentTCB == NULL )\r
                        {\r
-                               /* As this is the first task it must also be the current task. */\r
+                               /* There are no other tasks, or all the other tasks are in\r
+                               the suspended state - make this the current task. */\r
                                pxCurrentTCB =  pxNewTCB;\r
 \r
-                               /* This is the first task to be created so do the preliminary\r
-                               initialisation required.  We will not recover if this call\r
-                               fails, but we will report the failure. */\r
-                               prvInitialiseTaskLists();\r
+                               if( uxCurrentNumberOfTasks == ( unsigned portBASE_TYPE ) 1 )\r
+                               {\r
+                                       /* This is the first task to be created so do the preliminary\r
+                                       initialisation required.  We will not recover if this call\r
+                                       fails, but we will report the failure. */\r
+                                       prvInitialiseTaskLists();\r
+                               }\r
                        }\r
                        else\r
                        {\r
@@ -893,10 +897,31 @@ tskTCB * pxNewTCB;
                }\r
                portEXIT_CRITICAL();\r
 \r
-               /* We may have just suspended the current task. */\r
-               if( ( ( void * ) pxTaskToSuspend == NULL ) && ( xSchedulerRunning != pdFALSE ) )\r
+               if( ( void * ) pxTaskToSuspend == NULL )\r
                {\r
-                       portYIELD_WITHIN_API();\r
+                       if( xSchedulerRunning != pdFALSE )\r
+                       {\r
+                               /* We have just suspended the current task. */\r
+                               portYIELD_WITHIN_API();\r
+                       }\r
+                       else\r
+                       {\r
+                               /* The scheduler is not running, but the task that was pointed\r
+                               to by pxCurrentTCB has just been suspended and pxCurrentTCB\r
+                               must be adjusted to point to a different task. */\r
+                               if( uxCurrentNumberOfTasks == 1 )\r
+                               {\r
+                                       /* No other tasks are defined, so set pxCurrentTCB back to\r
+                                       NULL so when the next task is created pxCurrentTCB will\r
+                                       be set to point to it no matter what its relative priority\r
+                                       is. */\r
+                                       pxCurrentTCB = NULL;\r
+                               }\r
+                               else\r
+                               {\r
+                                       vTaskSwitchContext();\r
+                               }\r
+                       }\r
                }\r
        }\r
 \r