Update some standard demo task implementations so they can be used with the cooperative scheduler.

This commit is contained in:
Richard Barry 2013-11-07 14:04:05 +00:00
parent 5aabe4f8fb
commit 40d2e74417
7 changed files with 105 additions and 43 deletions

View file

@ -234,6 +234,10 @@ short sErrorEverOccurred = pdFALSE;
/* Increment the variable we are going to post next time round. The
consumer will expect the numbers to follow in numerical order. */
++usValue;
#if configUSE_PREEMPTION == 0
taskYIELD();
#endif
}
}
}
@ -271,6 +275,15 @@ short sErrorEverOccurred = pdFALSE;
round. */
++usExpectedValue;
}
#if configUSE_PREEMPTION == 0
{
if( pxQueueParameters->xBlockTime == 0 )
{
taskYIELD();
}
}
#endif
}
}
}

View file

@ -446,6 +446,10 @@ xSemaphoreHandle xMutex = ( xSemaphoreHandle ) pvParameters;
mutex, and block when it finds it cannot obtain it. */
vTaskResume( xHighPriorityMutexTask );
#if configUSE_PREEMPTION == 0
taskYIELD();
#endif
/* Ensure the task is reporting it priority as blocked and not
suspended (as it would have done in versions up to V7.5.3). */
#if( INCLUDE_eTaskGetState == 1 )
@ -490,6 +494,10 @@ xSemaphoreHandle xMutex = ( xSemaphoreHandle ) pvParameters;
xErrorDetected = pdTRUE;
}
#if configUSE_PREEMPTION == 0
taskYIELD();
#endif
/* Check that the guarded variable did indeed increment... */
if( ulGuardedVariable != 1 )
{

View file

@ -363,6 +363,10 @@ unsigned portLONG ulValue;
xErrorDetected = pdTRUE;
}
#if configUSE_PREEMPTION == 0
taskYIELD();
#endif
/* By the time we get here the data should have been removed from
the queue. */
if( uxQueueMessagesWaiting( xQueue ) != 0 )
@ -380,6 +384,10 @@ unsigned portLONG ulValue;
xErrorDetected = pdTRUE;
}
#if configUSE_PREEMPTION == 0
taskYIELD();
#endif
/* All the other tasks should now have successfully peeked the data.
The data is still in the queue so we should be able to receive it. */
ulValue = 0;
@ -407,6 +415,10 @@ unsigned portLONG ulValue;
vTaskResume( xHighPriorityTask );
vTaskResume( xHighestPriorityTask );
#if( configUSE_PREEMPTION == 0 )
taskYIELD();
#endif
ulValue = 0xaabbaabb;
if( xQueueSendToFront( xQueue, &ulValue, qpeekNO_BLOCK ) != pdPASS )
{
@ -415,6 +427,10 @@ unsigned portLONG ulValue;
xErrorDetected = pdTRUE;
}
#if configUSE_PREEMPTION == 0
taskYIELD();
#endif
/* This time we should find that the queue is empty. The high priority
task actually removed the data rather than just peeking it. */
if( xQueuePeek( xQueue, &ulValue, qpeekNO_BLOCK ) != errQUEUE_EMPTY )

View file

@ -178,6 +178,10 @@ unsigned long ulValue, ulStatus = pdPASS, x;
error. */
ulLoopCounter++;
}
#if( configUSE_PREEMPTION == 0 )
taskYIELD();
#endif
}
}
/*-----------------------------------------------------------*/

View file

@ -319,6 +319,10 @@ xQueueHandle xQueueInUse;
xQueueSetTasksStatus = pdFAIL;
}
#if( configUSE_PREEMPTION == 0 )
taskYIELD();
#endif
ulTaskTxValue++;
/* If the Tx value has reached the range used by the ISR then set it

View file

@ -257,6 +257,11 @@ unsigned portBASE_TYPE uxOurPriority;
( *pulCounter )++;
}
vTaskPrioritySet( NULL, uxOurPriority );
#if( configUSE_PREEMPTION == 0 )
taskYIELD();
#endif
configASSERT( ( uxTaskPriorityGet( NULL ) == uxOurPriority ) );
}
}
@ -300,6 +305,10 @@ short sError = pdFALSE;
}
vTaskResume( xContinuousIncrementHandle );
#if( configUSE_PREEMPTION == 0 )
taskYIELD();
#endif
#if( INCLUDE_eTaskGetState == 1 )
{
configASSERT( eTaskGetState( xContinuousIncrementHandle ) == eReady );
@ -344,6 +353,10 @@ short sError = pdFALSE;
task has suspended itself with a known value in the counter variable. */
vTaskResume( xLimitedIncrementHandle );
#if( configUSE_PREEMPTION == 0 )
taskYIELD();
#endif
/* This task should not run again until xLimitedIncrementHandle has
suspended itself. */
#if( INCLUDE_eTaskGetState == 1 )
@ -368,6 +381,10 @@ short sError = pdFALSE;
/* Resume the continuous count task and do it all again. */
vTaskResume( xContinuousIncrementHandle );
#if( configUSE_PREEMPTION == 0 )
taskYIELD();
#endif
}
}
/*-----------------------------------------------------------*/