Преглед изворни кода

vCoRoutineScheduleFix

(cherry picked from commit 1edbd44db107225b7bc6342a7da5680cc12ad22f)
Zim Kalinowski пре 4 година
родитељ
комит
12bf160f3d
1 измењених фајлова са 24 додато и 19 уклоњено
  1. 24 19
      components/freertos/croutine.c

+ 24 - 19
components/freertos/croutine.c

@@ -281,31 +281,36 @@
 
     void vCoRoutineSchedule( void )
     {
-        /* See if any co-routines readied by events need moving to the ready lists. */
-        prvCheckPendingReadyList();
+        /* Only run a co-routine after prvInitialiseCoRoutineLists() has been
+         * called.  prvInitialiseCoRoutineLists() is called automatically when a
+         * co-routine is created. */
+        if( pxDelayedCoRoutineList != NULL )
+        {
+            /* See if any co-routines readied by events need moving to the ready lists. */
+            prvCheckPendingReadyList();
 
-        /* See if any delayed co-routines have timed out. */
-        prvCheckDelayedList();
+            /* See if any delayed co-routines have timed out. */
+            prvCheckDelayedList();
 
-        /* Find the highest priority queue that contains ready co-routines. */
-        while( listLIST_IS_EMPTY( &( pxReadyCoRoutineLists[ uxTopCoRoutineReadyPriority ] ) ) )
-        {
-            if( uxTopCoRoutineReadyPriority == 0 )
+            /* Find the highest priority queue that contains ready co-routines. */
+            while( listLIST_IS_EMPTY( &( pxReadyCoRoutineLists[ uxTopCoRoutineReadyPriority ] ) ) )
             {
-                /* No more co-routines to check. */
-                return;
-            }
-            --uxTopCoRoutineReadyPriority;
-        }
+                if( uxTopCoRoutineReadyPriority == 0 )
+                {
+                    /* No more co-routines to check. */
+                    return;
+                }
 
-        /* listGET_OWNER_OF_NEXT_ENTRY walks through the list, so the co-routines
-         * of the same priority get an equal share of the processor time. */
-        listGET_OWNER_OF_NEXT_ENTRY( pxCurrentCoRoutine, &( pxReadyCoRoutineLists[ uxTopCoRoutineReadyPriority ] ) );
+                --uxTopCoRoutineReadyPriority;
+            }
 
-        /* Call the co-routine. */
-        ( pxCurrentCoRoutine->pxCoRoutineFunction )( pxCurrentCoRoutine, pxCurrentCoRoutine->uxIndex );
+            /* listGET_OWNER_OF_NEXT_ENTRY walks through the list, so the co-routines
+             * of the same priority get an equal share of the processor time. */
+            listGET_OWNER_OF_NEXT_ENTRY( pxCurrentCoRoutine, &( pxReadyCoRoutineLists[ uxTopCoRoutineReadyPriority ] ) );
 
-        return;
+            /* Call the co-routine. */
+            ( pxCurrentCoRoutine->pxCoRoutineFunction )( pxCurrentCoRoutine, pxCurrentCoRoutine->uxIndex );
+        }
     }
 /*-----------------------------------------------------------*/