sashiono wrote on Wednesday, September 12, 2007:
proposed change/addition to vCoRoutineSchedule to xCoRoutineSchedule
instead of returning void I would like to return the true if a co-routine is ready to be scheduled, otherwise false if all the co-routines are blocked.
something like this
signed portBASE_TYPE xCoRoutineSchedule( void )
{
/* 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();
/* Find the highest priority queue that contains ready co-routines. */
while( listLIST_IS_EMPTY( &( pxReadyCoRoutineLists[ uxTopCoRoutineReadyPriority ] ) ) )
{
if( uxTopCoRoutineReadyPriority == 0 )
{
/* No more co-routines to check. */
return pdFALSE;
}
--uxTopCoRoutineReadyPriority;
}
/* 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 ] ) );
/* Call the co-routine. */
( pxCurrentCoRoutine->pxCoRoutineFunction )( pxCurrentCoRoutine, pxCurrentCoRoutine->uxIndex );
return pdTRUE;
}
The reason this would be useful is for power reduction for example, the IdleHook can look something like this now.
void vApplicationIdleHook( void )
{
if(xCoRoutineSchedule() == pdFALSE)
{
//Idle the CPU
PCON = 0x1; //IDle Mode
}
}
I haven’t tested this yet, but I think it should work fine.