34 #if( configUSE_CO_ROUTINES != 0 ) 40 #ifdef portREMOVE_STATIC_QUALIFIER 47 static List_t xDelayedCoRoutineList1;
48 static List_t xDelayedCoRoutineList2;
49 static List_t * pxDelayedCoRoutineList;
50 static List_t * pxOverflowDelayedCoRoutineList;
51 static List_t xPendingReadyCoRoutineList;
56 static TickType_t xCoRoutineTickCount = 0, xLastTickCount = 0, xPassedTicks = 0;
59 #define corINITIAL_STATE ( 0 ) 68 #define prvAddCoRoutineToReadyQueue( pxCRCB ) \ 70 if( pxCRCB->uxPriority > uxTopCoRoutineReadyPriority ) \ 72 uxTopCoRoutineReadyPriority = pxCRCB->uxPriority; \ 74 vListInsertEnd( ( List_t * ) &( pxReadyCoRoutineLists[ pxCRCB->uxPriority ] ), &( pxCRCB->xGenericListItem ) ); \ 81 static void prvInitialiseCoRoutineLists(
void );
89 static void prvCheckPendingReadyList(
void );
99 static void prvCheckDelayedList(
void );
114 if( pxCurrentCoRoutine ==
NULL )
116 pxCurrentCoRoutine = pxCoRoutine;
117 prvInitialiseCoRoutineLists();
127 pxCoRoutine->
uxState = corINITIAL_STATE;
129 pxCoRoutine->
uxIndex = uxIndex;
147 prvAddCoRoutineToReadyQueue( pxCoRoutine );
166 xTimeToWake = xCoRoutineTickCount + xTicksToDelay;
176 if( xTimeToWake < xCoRoutineTickCount )
198 static void prvCheckPendingReadyList(
void )
216 prvAddCoRoutineToReadyQueue( pxUnblockedCRCB );
221 static void prvCheckDelayedList(
void )
226 while( xPassedTicks )
228 xCoRoutineTickCount++;
232 if( xCoRoutineTickCount == 0 )
238 pxTemp = pxDelayedCoRoutineList;
239 pxDelayedCoRoutineList = pxOverflowDelayedCoRoutineList;
240 pxOverflowDelayedCoRoutineList = pxTemp;
271 prvAddCoRoutineToReadyQueue( pxCRCB );
275 xLastTickCount = xCoRoutineTickCount;
282 prvCheckPendingReadyList();
285 prvCheckDelayedList();
288 while(
listLIST_IS_EMPTY( &( pxReadyCoRoutineLists[ uxTopCoRoutineReadyPriority ] ) ) )
290 if( uxTopCoRoutineReadyPriority == 0 )
295 --uxTopCoRoutineReadyPriority;
309 static void prvInitialiseCoRoutineLists(
void )
324 pxDelayedCoRoutineList = &xDelayedCoRoutineList1;
325 pxOverflowDelayedCoRoutineList = &xDelayedCoRoutineList2;
#define listGET_LIST_ITEM_VALUE(pxListItem)
#define listGET_OWNER_OF_NEXT_ENTRY(pxTCB, pxList)
void *configLIST_VOLATILE pvContainer
UBaseType_t uxListRemove(ListItem_t *const pxItemToRemove) PRIVILEGED_FUNCTION
ListItem_t xEventListItem
#define portENABLE_INTERRUPTS()
#define portDISABLE_INTERRUPTS()
BaseType_t xCoRoutineCreate(crCOROUTINE_CODE pxCoRoutineCode, UBaseType_t uxPriority, UBaseType_t uxIndex)
void vListInsertEnd(List_t *const pxList, ListItem_t *const pxNewListItem) PRIVILEGED_FUNCTION
void * pvPortMalloc(size_t xSize) PRIVILEGED_FUNCTION
#define listSET_LIST_ITEM_VALUE(pxListItem, xValue)
#define listLIST_IS_EMPTY(pxList)
unsigned long UBaseType_t
#define listSET_LIST_ITEM_OWNER(pxListItem, pxOwner)
TickType_t xTaskGetTickCount(void) PRIVILEGED_FUNCTION
#define errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY
#define listGET_OWNER_OF_HEAD_ENTRY(pxList)
#define configMAX_CO_ROUTINE_PRIORITIES
void vCoRoutineSchedule(void)
void vCoRoutineAddToDelayedList(TickType_t xTicksToDelay, List_t *pxEventList)
void vListInsert(List_t *const pxList, ListItem_t *const pxNewListItem) PRIVILEGED_FUNCTION
BaseType_t xCoRoutineRemoveFromEventList(const List_t *pxEventList)
crCOROUTINE_CODE pxCoRoutineFunction
ListItem_t xGenericListItem
void(* crCOROUTINE_CODE)(CoRoutineHandle_t, UBaseType_t)
void vListInitialise(List_t *const pxList) PRIVILEGED_FUNCTION
void vListInitialiseItem(ListItem_t *const pxItem) PRIVILEGED_FUNCTION