|
45 | 45 | static List_t pxReadyCoRoutineLists[ configMAX_CO_ROUTINE_PRIORITIES ]; /*< Prioritised ready co-routines. */
|
46 | 46 | static List_t xDelayedCoRoutineList1; /*< Delayed co-routines. */
|
47 | 47 | static List_t xDelayedCoRoutineList2; /*< Delayed co-routines (two lists are used - one for delays that have overflowed the current tick count. */
|
48 |
| -static List_t * pxDelayedCoRoutineList; /*< Points to the delayed co-routine list currently being used. */ |
49 |
| -static List_t * pxOverflowDelayedCoRoutineList; /*< Points to the delayed co-routine list currently being used to hold co-routines that have overflowed the current tick count. */ |
| 48 | +static List_t * pxDelayedCoRoutineList = NULL; /*< Points to the delayed co-routine list currently being used. */ |
| 49 | +static List_t * pxOverflowDelayedCoRoutineList = NULL; /*< Points to the delayed co-routine list currently being used to hold co-routines that have overflowed the current tick count. */ |
50 | 50 | static List_t xPendingReadyCoRoutineList; /*< Holds co-routines that have been readied by an external event. They cannot be added directly to the ready lists as the ready lists cannot be accessed by interrupts. */
|
51 | 51 |
|
52 | 52 | /* Other file private variables. --------------------------------*/
|
@@ -277,29 +277,35 @@ CRCB_t *pxCRCB;
|
277 | 277 |
|
278 | 278 | void vCoRoutineSchedule( void )
|
279 | 279 | {
|
280 |
| - /* See if any co-routines readied by events need moving to the ready lists. */ |
281 |
| - prvCheckPendingReadyList(); |
| 280 | + /* Only run a co-routine after prvInitialiseCoRoutineLists() has been |
| 281 | + called. prvInitialiseCoRoutineLists() is called automatically when a |
| 282 | + co-routine is created. */ |
| 283 | + if( pxDelayedCoRoutineList != NULL ) |
| 284 | + { |
| 285 | + /* See if any co-routines readied by events need moving to the ready lists. */ |
| 286 | + prvCheckPendingReadyList(); |
282 | 287 |
|
283 |
| - /* See if any delayed co-routines have timed out. */ |
284 |
| - prvCheckDelayedList(); |
| 288 | + /* See if any delayed co-routines have timed out. */ |
| 289 | + prvCheckDelayedList(); |
285 | 290 |
|
286 |
| - /* Find the highest priority queue that contains ready co-routines. */ |
287 |
| - while( listLIST_IS_EMPTY( &( pxReadyCoRoutineLists[ uxTopCoRoutineReadyPriority ] ) ) ) |
288 |
| - { |
289 |
| - if( uxTopCoRoutineReadyPriority == 0 ) |
| 291 | + /* Find the highest priority queue that contains ready co-routines. */ |
| 292 | + while( listLIST_IS_EMPTY( &( pxReadyCoRoutineLists[ uxTopCoRoutineReadyPriority ] ) ) ) |
290 | 293 | {
|
291 |
| - /* No more co-routines to check. */ |
292 |
| - return; |
| 294 | + if( uxTopCoRoutineReadyPriority == 0 ) |
| 295 | + { |
| 296 | + /* No more co-routines to check. */ |
| 297 | + return; |
| 298 | + } |
| 299 | + --uxTopCoRoutineReadyPriority; |
293 | 300 | }
|
294 |
| - --uxTopCoRoutineReadyPriority; |
295 |
| - } |
296 | 301 |
|
297 |
| - /* listGET_OWNER_OF_NEXT_ENTRY walks through the list, so the co-routines |
298 |
| - of the same priority get an equal share of the processor time. */ |
299 |
| - listGET_OWNER_OF_NEXT_ENTRY( pxCurrentCoRoutine, &( pxReadyCoRoutineLists[ uxTopCoRoutineReadyPriority ] ) ); |
| 302 | + /* listGET_OWNER_OF_NEXT_ENTRY walks through the list, so the co-routines |
| 303 | + of the same priority get an equal share of the processor time. */ |
| 304 | + listGET_OWNER_OF_NEXT_ENTRY( pxCurrentCoRoutine, &( pxReadyCoRoutineLists[ uxTopCoRoutineReadyPriority ] ) ); |
300 | 305 |
|
301 |
| - /* Call the co-routine. */ |
302 |
| - ( pxCurrentCoRoutine->pxCoRoutineFunction )( pxCurrentCoRoutine, pxCurrentCoRoutine->uxIndex ); |
| 306 | + /* Call the co-routine. */ |
| 307 | + ( pxCurrentCoRoutine->pxCoRoutineFunction )( pxCurrentCoRoutine, pxCurrentCoRoutine->uxIndex ); |
| 308 | + } |
303 | 309 |
|
304 | 310 | return;
|
305 | 311 | }
|
|
0 commit comments