mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-12-08 12:45:22 -05:00
Update some standard demo task implementations so they can be used with the cooperative scheduler.
This commit is contained in:
parent
5aabe4f8fb
commit
40d2e74417
7 changed files with 105 additions and 43 deletions
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
FreeRTOS V7.5.3 - Copyright (C) 2013 Real Time Engineers Ltd.
|
||||
FreeRTOS V7.5.3 - Copyright (C) 2013 Real Time Engineers Ltd.
|
||||
All rights reserved
|
||||
|
||||
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
|
||||
|
|
@ -64,7 +64,7 @@
|
|||
*/
|
||||
|
||||
|
||||
/*
|
||||
/*
|
||||
* Tests the behaviour when data is peeked from a queue when there are
|
||||
* multiple tasks blocked on the queue.
|
||||
*/
|
||||
|
|
@ -124,10 +124,10 @@ xQueueHandle xQueue;
|
|||
xQueue = xQueueCreate( qpeekQUEUE_LENGTH, sizeof( unsigned portLONG ) );
|
||||
|
||||
/* vQueueAddToRegistry() adds the queue to the queue registry, if one is
|
||||
in use. The queue registry is provided as a means for kernel aware
|
||||
in use. The queue registry is provided as a means for kernel aware
|
||||
debuggers to locate queues and has no purpose if a kernel aware debugger
|
||||
is not being used. The call to vQueueAddToRegistry() will be removed
|
||||
by the pre-processor if configQUEUE_REGISTRY_SIZE is not defined or is
|
||||
by the pre-processor if configQUEUE_REGISTRY_SIZE is not defined or is
|
||||
defined to be less than 1. */
|
||||
vQueueAddToRegistry( xQueue, ( signed portCHAR * ) "QPeek_Test_Queue" );
|
||||
|
||||
|
|
@ -149,7 +149,7 @@ unsigned portLONG ulValue;
|
|||
#ifdef USE_STDIO
|
||||
{
|
||||
void vPrintDisplayMessage( const portCHAR * const * ppcMessageToSend );
|
||||
|
||||
|
||||
const portCHAR * const pcTaskStartMsg = "Queue peek test started.\r\n";
|
||||
|
||||
/* Queue a message for printing to say the task has started. */
|
||||
|
|
@ -202,7 +202,7 @@ unsigned portLONG ulValue;
|
|||
xErrorDetected = pdTRUE;
|
||||
}
|
||||
|
||||
/* Now we will block again as the queue is once more empty. The low
|
||||
/* Now we will block again as the queue is once more empty. The low
|
||||
priority task can then execute again. */
|
||||
if( xQueuePeek( xQueue, &ulValue, portMAX_DELAY ) != pdPASS )
|
||||
{
|
||||
|
|
@ -245,7 +245,7 @@ unsigned portLONG ulValue;
|
|||
xErrorDetected = pdTRUE;
|
||||
}
|
||||
|
||||
vTaskSuspend( NULL );
|
||||
vTaskSuspend( NULL );
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
|
@ -300,7 +300,7 @@ unsigned portLONG ulValue;
|
|||
xErrorDetected = pdTRUE;
|
||||
}
|
||||
|
||||
vTaskSuspend( NULL );
|
||||
vTaskSuspend( NULL );
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
|
@ -353,7 +353,7 @@ unsigned portLONG ulValue;
|
|||
|
||||
for( ;; )
|
||||
{
|
||||
/* Write some data to the queue. This should unblock the highest
|
||||
/* Write some data to the queue. This should unblock the highest
|
||||
priority task that is waiting to peek data from the queue. */
|
||||
ulValue = 0x11223344;
|
||||
if( xQueueSendToBack( xQueue, &ulValue, qpeekNO_BLOCK ) != pdPASS )
|
||||
|
|
@ -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;
|
||||
|
|
@ -393,7 +401,7 @@ unsigned portLONG ulValue;
|
|||
{
|
||||
/* We did not receive the expected value. */
|
||||
}
|
||||
|
||||
|
||||
/* Lets just delay a while as this is an intensive test as we don't
|
||||
want to starve other tests of processing time. */
|
||||
vTaskDelay( qpeekSHORT_DELAY );
|
||||
|
|
@ -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 )
|
||||
|
|
@ -427,7 +443,7 @@ unsigned portLONG ulValue;
|
|||
and repeat the whole thing. The medium priority task should not be
|
||||
suspended as it was not able to peek the data in this last case. */
|
||||
vTaskResume( xHighPriorityTask );
|
||||
vTaskResume( xHighestPriorityTask );
|
||||
vTaskResume( xHighestPriorityTask );
|
||||
|
||||
/* Lets just delay a while as this is an intensive test as we don't
|
||||
want to starve other tests of processing time. */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue