2 * FreeRTOS Kernel V10.0.0
\r
3 * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
\r
5 * Permission is hereby granted, free of charge, to any person obtaining a copy of
\r
6 * this software and associated documentation files (the "Software"), to deal in
\r
7 * the Software without restriction, including without limitation the rights to
\r
8 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
\r
9 * the Software, and to permit persons to whom the Software is furnished to do so,
\r
10 * subject to the following conditions:
\r
12 * The above copyright notice and this permission notice shall be included in all
\r
13 * copies or substantial portions of the Software. If you wish to use our Amazon
\r
14 * FreeRTOS name, please do so in a fair use way that does not cause confusion.
\r
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
\r
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
\r
18 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
\r
19 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
\r
20 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
\r
21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\r
23 * http://www.FreeRTOS.org
\r
24 * http://aws.amazon.com/freertos
\r
26 * 1 tab == 4 spaces!
\r
30 * Tests the use of queue sets.
\r
32 * A receive task creates a number of queues and adds them to a queue set before
\r
33 * blocking on the queue set receive. A transmit task and (optionally) an
\r
34 * interrupt repeatedly unblocks the receive task by sending messages to the
\r
35 * queues in a pseudo random order. The receive task removes the messages from
\r
36 * the queues and flags an error if the received message does not match that
\r
37 * expected. The task sends values in the range 0 to
\r
38 * queuesetINITIAL_ISR_TX_VALUE, and the ISR sends value in the range
\r
39 * queuesetINITIAL_ISR_TX_VALUE to ULONG_MAX.
\r
43 /* Standard includes. */
\r
47 /* Kernel includes. */
\r
48 #include "FreeRTOS.h"
\r
52 /* Demo includes. */
\r
53 #include "QueueSet.h"
\r
55 /* The number of queues that are created and added to the queue set. */
\r
56 #define queuesetNUM_QUEUES_IN_SET 3
\r
58 /* The length of each created queue. */
\r
59 #define queuesetQUEUE_LENGTH 3
\r
61 /* Block times used in this demo. A block time or 0 means "don't block". */
\r
62 #define queuesetSHORT_DELAY 200
\r
63 #define queuesetDONT_BLOCK 0
\r
65 /* Messages are sent in incrementing order from both a task and an interrupt.
\r
66 The task sends values in the range 0 to 0xfffe, and the interrupt sends values
\r
67 in the range of 0xffff to ULONG_MAX. */
\r
68 #define queuesetINITIAL_ISR_TX_VALUE 0xffffUL
\r
70 /* The priorities used in this demo. */
\r
71 #define queuesetLOW_PRIORITY ( tskIDLE_PRIORITY )
\r
72 #define queuesetMEDIUM_PRIORITY ( queuesetLOW_PRIORITY + 1 )
\r
74 /* For test purposes the priority of the sending task is changed after every
\r
75 queuesetPRIORITY_CHANGE_LOOPS number of values are sent to a queue. */
\r
76 #define queuesetPRIORITY_CHANGE_LOOPS ( ( queuesetNUM_QUEUES_IN_SET * queuesetQUEUE_LENGTH ) * 2 )
\r
78 /* The ISR sends to the queue every queuesetISR_TX_PERIOD ticks. */
\r
79 #define queuesetISR_TX_PERIOD ( 100UL )
\r
81 /* A delay inserted when the Tx task changes its priority to be above the idle
\r
82 task priority to ensure the idle priority tasks get some CPU time before the
\r
83 next iteration of the queue set Tx task. */
\r
84 #define queuesetTX_LOOP_DELAY pdMS_TO_TICKS( ( TickType_t ) 200 )
\r
86 /* The allowable maximum deviation between a received value and the expected
\r
87 received value. A deviation will occur when data is received from a queue
\r
88 inside an ISR in between a task receiving from a queue and the task checking
\r
89 the received value. */
\r
90 #define queuesetALLOWABLE_RX_DEVIATION 3
\r
92 /* Ignore values that are at the boundaries of allowable values to make the
\r
93 testing of limits easier (don't have to deal with wrapping values). */
\r
94 #define queuesetIGNORED_BOUNDARY ( queuesetALLOWABLE_RX_DEVIATION * 2 )
\r
98 eEqualPriority = 0, /* Tx and Rx tasks have the same priority. */
\r
99 eTxHigherPriority, /* The priority of the Tx task is above that of the Rx task. */
\r
100 eTxLowerPriority /* The priority of the Tx task is below that of the Rx task. */
\r
101 } eRelativePriorities;
\r
104 * The task that periodically sends to the queue set.
\r
106 static void prvQueueSetSendingTask( void *pvParameters );
\r
109 * The task that reads from the queue set.
\r
111 static void prvQueueSetReceivingTask( void *pvParameters );
\r
114 * Check the value received from a queue is the expected value. Some values
\r
115 * originate from the send task, some values originate from the ISR, with the
\r
116 * range of the value being used to distinguish between the two message
\r
119 static void prvCheckReceivedValue( uint32_t ulReceived );
\r
122 * For purposes of test coverage, functions that read from and write to a
\r
123 * queue set from an ISR respectively.
\r
125 static void prvReceiveFromQueueInSetFromISR( void );
\r
126 static void prvSendToQueueInSetFromISR( void );
\r
129 * Create the queues and add them to a queue set before resuming the Tx
\r
132 static void prvSetupTest( void );
\r
135 * Checks a value received from a queue falls within the range of expected
\r
138 static BaseType_t prvCheckReceivedValueWithinExpectedRange( uint32_t ulReceived, uint32_t ulExpectedReceived );
\r
141 * Increase test coverage by occasionally change the priorities of the two tasks
\r
142 * relative to each other. */
\r
143 static void prvChangeRelativePriorities( void );
\r
146 * Local pseudo random number seed and return functions. Used to avoid calls
\r
147 * to the standard library.
\r
149 static size_t prvRand( void );
\r
150 static void prvSRand( size_t uxSeed );
\r
152 /*-----------------------------------------------------------*/
\r
154 /* The queues that are added to the set. */
\r
155 static QueueHandle_t xQueues[ queuesetNUM_QUEUES_IN_SET ] = { 0 };
\r
157 /* Counts how many times each queue in the set is used to ensure all the
\r
158 queues are used. */
\r
159 static uint32_t ulQueueUsedCounter[ queuesetNUM_QUEUES_IN_SET ] = { 0 };
\r
161 /* The handle of the queue set to which the queues are added. */
\r
162 static QueueSetHandle_t xQueueSet;
\r
164 /* If the prvQueueSetReceivingTask() task has not detected any errors then
\r
165 it increments ulCycleCounter on each iteration.
\r
166 xAreQueueSetTasksStillRunning() returns pdPASS if the value of
\r
167 ulCycleCounter has changed between consecutive calls, and pdFALSE if
\r
168 ulCycleCounter has stopped incrementing (indicating an error condition). */
\r
169 static volatile uint32_t ulCycleCounter = 0UL;
\r
171 /* Set to pdFAIL if an error is detected by any queue set task.
\r
172 ulCycleCounter will only be incremented if xQueueSetTasksSatus equals pdPASS. */
\r
173 static volatile BaseType_t xQueueSetTasksStatus = pdPASS;
\r
175 /* Just a flag to let the function that writes to a queue from an ISR know that
\r
176 the queues are setup and can be used. */
\r
177 static volatile BaseType_t xSetupComplete = pdFALSE;
\r
179 /* The value sent to the queue from the ISR is file scope so the
\r
180 xAreQueeuSetTasksStillRunning() function can check it is incrementing as
\r
182 static volatile uint32_t ulISRTxValue = queuesetINITIAL_ISR_TX_VALUE;
\r
184 /* Used by the pseudo random number generator. */
\r
185 static size_t uxNextRand = 0;
\r
187 /* The task handles are stored so their priorities can be changed. */
\r
188 TaskHandle_t xQueueSetSendingTask, xQueueSetReceivingTask;
\r
190 /*-----------------------------------------------------------*/
\r
192 void vStartQueueSetTasks( void )
\r
194 /* Create the tasks. */
\r
195 xTaskCreate( prvQueueSetSendingTask, "SetTx", configMINIMAL_STACK_SIZE, NULL, queuesetMEDIUM_PRIORITY, &xQueueSetSendingTask );
\r
197 if( xQueueSetSendingTask != NULL )
\r
199 xTaskCreate( prvQueueSetReceivingTask, "SetRx", configMINIMAL_STACK_SIZE, ( void * ) xQueueSetSendingTask, queuesetMEDIUM_PRIORITY, &xQueueSetReceivingTask );
\r
201 /* It is important that the sending task does not attempt to write to a
\r
202 queue before the queue has been created. It is therefore placed into
\r
203 the suspended state before the scheduler has started. It is resumed by
\r
204 the receiving task after the receiving task has created the queues and
\r
205 added the queues to the queue set. */
\r
206 vTaskSuspend( xQueueSetSendingTask );
\r
209 /*-----------------------------------------------------------*/
\r
211 BaseType_t xAreQueueSetTasksStillRunning( void )
\r
213 static uint32_t ulLastCycleCounter, ulLastISRTxValue = 0;
\r
214 static uint32_t ulLastQueueUsedCounter[ queuesetNUM_QUEUES_IN_SET ] = { 0 };
\r
215 BaseType_t xReturn = pdPASS, x;
\r
217 if( ulLastCycleCounter == ulCycleCounter )
\r
219 /* The cycle counter is no longer being incremented. Either one of the
\r
220 tasks is stalled or an error has been detected. */
\r
224 ulLastCycleCounter = ulCycleCounter;
\r
226 /* Ensure that all the queues in the set have been used. This ensures the
\r
227 test is working as intended and guards against the rand() in the Tx task
\r
228 missing some values. */
\r
229 for( x = 0; x < queuesetNUM_QUEUES_IN_SET; x++ )
\r
231 if( ulLastQueueUsedCounter[ x ] == ulQueueUsedCounter[ x ] )
\r
236 ulLastQueueUsedCounter[ x ] = ulQueueUsedCounter[ x ];
\r
239 /* Check the global status flag. */
\r
240 if( xQueueSetTasksStatus != pdPASS )
\r
245 /* Check that the ISR is still sending values to the queues too. */
\r
246 if( ulISRTxValue == ulLastISRTxValue )
\r
252 ulLastISRTxValue = ulISRTxValue;
\r
257 /*-----------------------------------------------------------*/
\r
259 static void prvQueueSetSendingTask( void *pvParameters )
\r
261 uint32_t ulTaskTxValue = 0;
\r
262 size_t uxQueueToWriteTo;
\r
263 QueueHandle_t xQueueInUse;
\r
265 /* Remove compiler warning about the unused parameter. */
\r
266 ( void ) pvParameters;
\r
268 /* Seed mini pseudo random number generator. */
\r
269 prvSRand( ( size_t ) &ulTaskTxValue );
\r
273 /* Generate the index for the queue to which a value is to be sent. */
\r
274 uxQueueToWriteTo = prvRand() % queuesetNUM_QUEUES_IN_SET;
\r
275 xQueueInUse = xQueues[ uxQueueToWriteTo ];
\r
277 /* Note which index is being written to to ensure all the queues are
\r
279 ( ulQueueUsedCounter[ uxQueueToWriteTo ] )++;
\r
281 /* Send to the queue to unblock the task that is waiting for data to
\r
282 arrive on a queue within the queue set to which this queue belongs. */
\r
283 if( xQueueSendToBack( xQueueInUse, &ulTaskTxValue, portMAX_DELAY ) != pdPASS )
\r
285 /* The send should always pass as an infinite block time was
\r
287 xQueueSetTasksStatus = pdFAIL;
\r
290 #if( configUSE_PREEMPTION == 0 )
\r
296 /* If the Tx value has reached the range used by the ISR then set it
\r
298 if( ulTaskTxValue == queuesetINITIAL_ISR_TX_VALUE )
\r
303 /* Increase test coverage by occasionally change the priorities of the
\r
304 two tasks relative to each other. */
\r
305 prvChangeRelativePriorities();
\r
308 /*-----------------------------------------------------------*/
\r
310 static void prvChangeRelativePriorities( void )
\r
312 static UBaseType_t ulLoops = 0;
\r
313 static eRelativePriorities ePriorities = eEqualPriority;
\r
315 /* Occasionally change the task priority relative to the priority of
\r
316 the receiving task. */
\r
318 if( ulLoops >= queuesetPRIORITY_CHANGE_LOOPS )
\r
322 switch( ePriorities )
\r
324 case eEqualPriority:
\r
325 /* Both tasks are running with medium priority. Now lower the
\r
326 priority of the receiving task so the Tx task has the higher
\r
327 relative priority. */
\r
328 vTaskPrioritySet( xQueueSetReceivingTask, queuesetLOW_PRIORITY );
\r
329 ePriorities = eTxHigherPriority;
\r
332 case eTxHigherPriority:
\r
333 /* The Tx task is running with a higher priority than the Rx
\r
334 task. Switch the priorities around so the Rx task has the
\r
335 higher relative priority. */
\r
336 vTaskPrioritySet( xQueueSetReceivingTask, queuesetMEDIUM_PRIORITY );
\r
337 vTaskPrioritySet( xQueueSetSendingTask, queuesetLOW_PRIORITY );
\r
338 ePriorities = eTxLowerPriority;
\r
341 case eTxLowerPriority:
\r
342 /* The Tx task is running with a lower priority than the Rx
\r
343 task. Make the priorities equal again. */
\r
344 vTaskPrioritySet( xQueueSetSendingTask, queuesetMEDIUM_PRIORITY );
\r
345 ePriorities = eEqualPriority;
\r
347 /* When both tasks are using a non-idle priority the queue set
\r
348 tasks will starve idle priority tasks of execution time - so
\r
349 relax a bit before the next iteration to minimise the impact. */
\r
350 vTaskDelay( queuesetTX_LOOP_DELAY );
\r
356 /*-----------------------------------------------------------*/
\r
358 static void prvQueueSetReceivingTask( void *pvParameters )
\r
360 uint32_t ulReceived;
\r
361 QueueHandle_t xActivatedQueue;
\r
362 TickType_t xBlockTime;
\r
364 /* Remove compiler warnings. */
\r
365 ( void ) pvParameters;
\r
367 /* Create the queues and add them to the queue set before resuming the Tx
\r
373 /* For test coverage reasons, the block time is dependent on the
\r
374 priority of this task - which changes during the test. When the task
\r
375 is at the idle priority it polls the queue set. */
\r
376 if( uxTaskPriorityGet( NULL ) == tskIDLE_PRIORITY )
\r
382 xBlockTime = portMAX_DELAY;
\r
385 /* Wait for a message to arrive on one of the queues in the set. */
\r
386 xActivatedQueue = xQueueSelectFromSet( xQueueSet, portMAX_DELAY );
\r
388 if( xActivatedQueue == NULL )
\r
390 if( xBlockTime != 0 )
\r
392 /* This should not happen as an infinite delay was used. */
\r
393 xQueueSetTasksStatus = pdFAIL;
\r
398 /* Reading from the queue should pass with a zero block time as
\r
399 this task will only run when something has been posted to a task
\r
400 in the queue set. */
\r
401 if( xQueueReceive( xActivatedQueue, &ulReceived, queuesetDONT_BLOCK ) != pdPASS )
\r
403 xQueueSetTasksStatus = pdFAIL;
\r
406 /* Ensure the value received was the value expected. This function
\r
407 manipulates file scope data and is also called from an ISR, hence
\r
408 the critical section. */
\r
409 taskENTER_CRITICAL();
\r
411 prvCheckReceivedValue( ulReceived );
\r
413 taskEXIT_CRITICAL();
\r
415 if( xQueueSetTasksStatus == pdPASS )
\r
422 /*-----------------------------------------------------------*/
\r
424 void vQueueSetAccessQueueSetFromISR( void )
\r
426 static uint32_t ulCallCount = 0;
\r
428 /* xSetupComplete is set to pdTRUE when the queues have been created and
\r
429 are available for use. */
\r
430 if( xSetupComplete == pdTRUE )
\r
432 /* It is intended that this function is called from the tick hook
\r
433 function, so each call is one tick period apart. */
\r
435 if( ulCallCount > queuesetISR_TX_PERIOD )
\r
439 /* First attempt to read from the queue set. */
\r
440 prvReceiveFromQueueInSetFromISR();
\r
442 /* Then write to the queue set. */
\r
443 prvSendToQueueInSetFromISR();
\r
447 /*-----------------------------------------------------------*/
\r
449 static void prvCheckReceivedValue( uint32_t ulReceived )
\r
451 static uint32_t ulExpectedReceivedFromTask = 0, ulExpectedReceivedFromISR = queuesetINITIAL_ISR_TX_VALUE;
\r
453 /* Values are received in tasks and interrupts. It is likely that the
\r
454 receiving task will sometimes get preempted by the receiving interrupt
\r
455 between reading a value from the queue and calling this function. When
\r
456 that happens, if the receiving interrupt calls this function the values
\r
457 will get passed into this function slightly out of order. For that
\r
458 reason the value passed in is tested against a small range of expected
\r
459 values, rather than a single absolute value. To make the range testing
\r
460 easier values in the range limits are ignored. */
\r
462 /* If the received value is equal to or greater than
\r
463 queuesetINITIAL_ISR_TX_VALUE then it was sent by an ISR. */
\r
464 if( ulReceived >= queuesetINITIAL_ISR_TX_VALUE )
\r
466 /* The value was sent from the ISR. */
\r
467 if( ( ulReceived - queuesetINITIAL_ISR_TX_VALUE ) < queuesetIGNORED_BOUNDARY )
\r
469 /* The value received is at the lower limit of the expected range.
\r
470 Don't test it and expect to receive one higher next time. */
\r
472 else if( ( ULONG_MAX - ulReceived ) <= queuesetIGNORED_BOUNDARY )
\r
474 /* The value received is at the higher limit of the expected range.
\r
475 Don't test it and expect to wrap soon. */
\r
479 /* Check the value against its expected value range. */
\r
480 if( prvCheckReceivedValueWithinExpectedRange( ulReceived, ulExpectedReceivedFromISR ) != pdPASS )
\r
482 xQueueSetTasksStatus = pdFAIL;
\r
486 configASSERT( xQueueSetTasksStatus );
\r
488 /* It is expected to receive an incrementing number. */
\r
489 ulExpectedReceivedFromISR++;
\r
490 if( ulExpectedReceivedFromISR == 0 )
\r
492 ulExpectedReceivedFromISR = queuesetINITIAL_ISR_TX_VALUE;
\r
497 /* The value was sent from the Tx task. */
\r
498 if( ulReceived < queuesetIGNORED_BOUNDARY )
\r
500 /* The value received is at the lower limit of the expected range.
\r
501 Don't test it, and expect to receive one higher next time. */
\r
503 else if( ( ( queuesetINITIAL_ISR_TX_VALUE - 1 ) - ulReceived ) <= queuesetIGNORED_BOUNDARY )
\r
505 /* The value received is at the higher limit of the expected range.
\r
506 Don't test it and expect to wrap soon. */
\r
510 /* Check the value against its expected value range. */
\r
511 if( prvCheckReceivedValueWithinExpectedRange( ulReceived, ulExpectedReceivedFromTask ) != pdPASS )
\r
513 xQueueSetTasksStatus = pdFAIL;
\r
517 configASSERT( xQueueSetTasksStatus );
\r
519 /* It is expected to receive an incrementing number. */
\r
520 ulExpectedReceivedFromTask++;
\r
521 if( ulExpectedReceivedFromTask >= queuesetINITIAL_ISR_TX_VALUE )
\r
523 ulExpectedReceivedFromTask = 0;
\r
527 /*-----------------------------------------------------------*/
\r
529 static BaseType_t prvCheckReceivedValueWithinExpectedRange( uint32_t ulReceived, uint32_t ulExpectedReceived )
\r
531 BaseType_t xReturn = pdPASS;
\r
533 if( ulReceived > ulExpectedReceived )
\r
535 configASSERT( ( ulReceived - ulExpectedReceived ) <= queuesetALLOWABLE_RX_DEVIATION );
\r
536 if( ( ulReceived - ulExpectedReceived ) > queuesetALLOWABLE_RX_DEVIATION )
\r
543 configASSERT( ( ulExpectedReceived - ulReceived ) <= queuesetALLOWABLE_RX_DEVIATION );
\r
544 if( ( ulExpectedReceived - ulReceived ) > queuesetALLOWABLE_RX_DEVIATION )
\r
552 /*-----------------------------------------------------------*/
\r
554 static void prvReceiveFromQueueInSetFromISR( void )
\r
556 QueueSetMemberHandle_t xActivatedQueue;
\r
557 uint32_t ulReceived;
\r
559 /* See if any of the queues in the set contain data. */
\r
560 xActivatedQueue = xQueueSelectFromSetFromISR( xQueueSet );
\r
562 if( xActivatedQueue != NULL )
\r
564 /* Reading from the queue for test purposes only. */
\r
565 if( xQueueReceiveFromISR( xActivatedQueue, &ulReceived, NULL ) != pdPASS )
\r
567 /* Data should have been available as the handle was returned from
\r
568 xQueueSelectFromSetFromISR(). */
\r
569 xQueueSetTasksStatus = pdFAIL;
\r
572 /* Ensure the value received was the value expected. */
\r
573 prvCheckReceivedValue( ulReceived );
\r
576 /*-----------------------------------------------------------*/
\r
578 static void prvSendToQueueInSetFromISR( void )
\r
580 static BaseType_t xQueueToWriteTo = 0;
\r
581 uint32_t ulTxValueSnapshot = ulISRTxValue;
\r
583 if( xQueueSendFromISR( xQueues[ xQueueToWriteTo ], ( void * ) &ulTxValueSnapshot, NULL ) == pdPASS )
\r
587 /* If the Tx value has wrapped then set it back to its initial value. */
\r
588 if( ulISRTxValue == 0UL )
\r
590 ulISRTxValue = queuesetINITIAL_ISR_TX_VALUE;
\r
593 /* Use a different queue next time. */
\r
595 if( xQueueToWriteTo >= queuesetNUM_QUEUES_IN_SET )
\r
597 xQueueToWriteTo = 0;
\r
601 /*-----------------------------------------------------------*/
\r
603 static void prvSetupTest( void )
\r
606 uint32_t ulValueToSend = 0;
\r
608 /* Ensure the queues are created and the queue set configured before the
\r
609 sending task is unsuspended.
\r
611 First Create the queue set such that it will be able to hold a message for
\r
612 every space in every queue in the set. */
\r
613 xQueueSet = xQueueCreateSet( queuesetNUM_QUEUES_IN_SET * queuesetQUEUE_LENGTH );
\r
615 for( x = 0; x < queuesetNUM_QUEUES_IN_SET; x++ )
\r
617 /* Create the queue and add it to the set. The queue is just holding
\r
619 xQueues[ x ] = xQueueCreate( queuesetQUEUE_LENGTH, sizeof( uint32_t ) );
\r
620 configASSERT( xQueues[ x ] );
\r
621 if( xQueueAddToSet( xQueues[ x ], xQueueSet ) != pdPASS )
\r
623 xQueueSetTasksStatus = pdFAIL;
\r
627 /* The queue has now been added to the queue set and cannot be added to
\r
629 if( xQueueAddToSet( xQueues[ x ], xQueueSet ) != pdFAIL )
\r
631 xQueueSetTasksStatus = pdFAIL;
\r
636 /* Attempt to remove a queue from a queue set it does not belong
\r
637 to (NULL being passed as the queue set in this case). */
\r
638 if( xQueueRemoveFromSet( xQueues[ 0 ], NULL ) != pdFAIL )
\r
640 /* It is not possible to successfully remove a queue from a queue
\r
641 set it does not belong to. */
\r
642 xQueueSetTasksStatus = pdFAIL;
\r
645 /* Attempt to remove a queue from the queue set it does belong to. */
\r
646 if( xQueueRemoveFromSet( xQueues[ 0 ], xQueueSet ) != pdPASS )
\r
648 /* It should be possible to remove the queue from the queue set it
\r
650 xQueueSetTasksStatus = pdFAIL;
\r
653 /* Add an item to the queue before attempting to add it back into the
\r
655 xQueueSend( xQueues[ 0 ], ( void * ) &ulValueToSend, 0 );
\r
656 if( xQueueAddToSet( xQueues[ 0 ], xQueueSet ) != pdFAIL )
\r
658 /* Should not be able to add a non-empty queue to a set. */
\r
659 xQueueSetTasksStatus = pdFAIL;
\r
662 /* Remove the item from the queue before adding the queue back into the
\r
663 set so the dynamic tests can begin. */
\r
664 xQueueReceive( xQueues[ 0 ], &ulValueToSend, 0 );
\r
665 if( xQueueAddToSet( xQueues[ 0 ], xQueueSet ) != pdPASS )
\r
667 /* If the queue was successfully removed from the queue set then it
\r
668 should be possible to add it back in again. */
\r
669 xQueueSetTasksStatus = pdFAIL;
\r
672 /* The task that sends to the queues is not running yet, so attempting to
\r
673 read from the queue set should fail. */
\r
674 if( xQueueSelectFromSet( xQueueSet, queuesetSHORT_DELAY ) != NULL )
\r
676 xQueueSetTasksStatus = pdFAIL;
\r
679 /* Resume the task that writes to the queues. */
\r
680 vTaskResume( xQueueSetSendingTask );
\r
682 /* Let the ISR access the queues also. */
\r
683 xSetupComplete = pdTRUE;
\r
685 /*-----------------------------------------------------------*/
\r
687 static size_t prvRand( void )
\r
689 uxNextRand = ( uxNextRand * ( size_t ) 1103515245 ) + ( size_t ) 12345;
\r
690 return ( uxNextRand / ( size_t ) 65536 ) % ( size_t ) 32768;
\r
692 /*-----------------------------------------------------------*/
\r
694 static void prvSRand( size_t uxSeed )
\r
696 uxNextRand = uxSeed;
\r