|
|
@@ -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 );
|
|
|
+ }
|
|
|
}
|
|
|
/*-----------------------------------------------------------*/
|
|
|
|