2 * FreeRTOS Kernel V10.0.1
\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.
\r
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
\r
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
\r
17 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
\r
18 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
\r
19 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
\r
20 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\r
22 * http://www.FreeRTOS.org
\r
23 * http://aws.amazon.com/freertos
\r
25 * 1 tab == 4 spaces!
\r
29 * Tests the use of queue sets.
\r
31 * A receive task creates a number of queues and adds them to a queue set before
\r
32 * blocking on the queue set receive. A transmit task and (optionally) an
\r
33 * interrupt repeatedly unblocks the receive task by sending messages to the
\r
34 * queues in a pseudo random order. The receive task removes the messages from
\r
35 * the queues and flags an error if the received message does not match that
\r
36 * expected. The task sends values in the range 0 to
\r
37 * queuesetINITIAL_ISR_TX_VALUE, and the ISR sends value in the range
\r
38 * queuesetINITIAL_ISR_TX_VALUE to ULONG_MAX.
\r
42 /* Standard includes. */
\r
46 /* Kernel includes. */
\r
47 #include "FreeRTOS.h"
\r
51 /* Demo includes. */
\r
52 #include "QueueSet.h"
\r
54 /* The number of queues that are created and added to the queue set. */
\r
55 #define queuesetNUM_QUEUES_IN_SET 3
\r
57 /* The length of each created queue. */
\r
58 #define queuesetQUEUE_LENGTH 3
\r
60 /* Block times used in this demo. A block time or 0 means "don't block". */
\r
61 #define queuesetSHORT_DELAY 200
\r
62 #define queuesetDONT_BLOCK 0
\r
64 /* Messages are sent in incrementing order from both a task and an interrupt.
\r
65 The task sends values in the range 0 to 0xfffe, and the interrupt sends values
\r
66 in the range of 0xffff to ULONG_MAX. */
\r
67 #define queuesetINITIAL_ISR_TX_VALUE 0xffffUL
\r
69 /* The priorities used in this demo. */
\r
70 #define queuesetLOW_PRIORITY ( tskIDLE_PRIORITY )
\r
71 #define queuesetMEDIUM_PRIORITY ( queuesetLOW_PRIORITY + 1 )
\r
73 /* For test purposes the priority of the sending task is changed after every
\r
74 queuesetPRIORITY_CHANGE_LOOPS number of values are sent to a queue. */
\r
75 #define queuesetPRIORITY_CHANGE_LOOPS ( ( queuesetNUM_QUEUES_IN_SET * queuesetQUEUE_LENGTH ) * 2 )
\r
77 /* The ISR sends to the queue every queuesetISR_TX_PERIOD ticks. */
\r
78 #define queuesetISR_TX_PERIOD ( 100UL )
\r
80 /* A delay inserted when the Tx task changes its priority to be above the idle
\r
81 task priority to ensure the idle priority tasks get some CPU time before the
\r
82 next iteration of the queue set Tx task. */
\r
83 #define queuesetTX_LOOP_DELAY pdMS_TO_TICKS( ( TickType_t ) 200 )
\r
85 /* The allowable maximum deviation between a received value and the expected
\r
86 received value. A deviation will occur when data is received from a queue
\r
87 inside an ISR in between a task receiving from a queue and the task checking
\r
88 the received value. */
\r
89 #define queuesetALLOWABLE_RX_DEVIATION 3
\r
91 /* Ignore values that are at the boundaries of allowable values to make the
\r
92 testing of limits easier (don't have to deal with wrapping values). */
\r
93 #define queuesetIGNORED_BOUNDARY ( queuesetALLOWABLE_RX_DEVIATION * 2 )
\r
97 eEqualPriority = 0, /* Tx and Rx tasks have the same priority. */
\r
98 eTxHigherPriority, /* The priority of the Tx task is above that of the Rx task. */
\r
99 eTxLowerPriority /* The priority of the Tx task is below that of the Rx task. */
\r
100 } eRelativePriorities;
\r
103 * The task that periodically sends to the queue set.
\r
105 static void prvQueueSetSendingTask( void *pvParameters );
\r
108 * The task that reads from the queue set.
\r
110 static void prvQueueSetReceivingTask( void *pvParameters );
\r
113 * Check the value received from a queue is the expected value. Some values
\r
114 * originate from the send task, some values originate from the ISR, with the
\r
115 * range of the value being used to distinguish between the two message
\r
118 static void prvCheckReceivedValue( uint32_t ulReceived );
\r
121 * For purposes of test coverage, functions that read from and write to a
\r
122 * queue set from an ISR respectively.
\r
124 static void prvReceiveFromQueueInSetFromISR( void );
\r
125 static void prvSendToQueueInSetFromISR( void );
\r
128 * Create the queues and add them to a queue set before resuming the Tx
\r
131 static void prvSetupTest( void );
\r
134 * Checks a value received from a queue falls within the range of expected
\r
137 static BaseType_t prvCheckReceivedValueWithinExpectedRange( uint32_t ulReceived, uint32_t ulExpectedReceived );
\r
140 * Increase test coverage by occasionally change the priorities of the two tasks
\r
141 * relative to each other. */
\r
142 static void prvChangeRelativePriorities( void );
\r
145 * Local pseudo random number seed and return functions. Used to avoid calls
\r
146 * to the standard library.
\r
148 static size_t prvRand( void );
\r
149 static void prvSRand( size_t uxSeed );
\r
151 /*-----------------------------------------------------------*/
\r
153 /* The queues that are added to the set. */
\r
154 static QueueHandle_t xQueues[ queuesetNUM_QUEUES_IN_SET ] = { 0 };
\r
156 /* Counts how many times each queue in the set is used to ensure all the
\r
157 queues are used. */
\r
158 static uint32_t ulQueueUsedCounter[ queuesetNUM_QUEUES_IN_SET ] = { 0 };
\r
160 /* The handle of the queue set to which the queues are added. */
\r
161 static QueueSetHandle_t xQueueSet;
\r
163 /* If the prvQueueSetReceivingTask() task has not detected any errors then
\r
164 it increments ulCycleCounter on each iteration.
\r
165 xAreQueueSetTasksStillRunning() returns pdPASS if the value of
\r
166 ulCycleCounter has changed between consecutive calls, and pdFALSE if
\r
167 ulCycleCounter has stopped incrementing (indicating an error condition). */
\r
168 static volatile uint32_t ulCycleCounter = 0UL;
\r
170 /* Set to pdFAIL if an error is detected by any queue set task.
\r
171 ulCycleCounter will only be incremented if xQueueSetTasksSatus equals pdPASS. */
\r
172 static volatile BaseType_t xQueueSetTasksStatus = pdPASS;
\r
174 /* Just a flag to let the function that writes to a queue from an ISR know that
\r
175 the queues are setup and can be used. */
\r
176 static volatile BaseType_t xSetupComplete = pdFALSE;
\r
178 /* The value sent to the queue from the ISR is file scope so the
\r
179 xAreQueeuSetTasksStillRunning() function can check it is incrementing as
\r
181 static volatile uint32_t ulISRTxValue = queuesetINITIAL_ISR_TX_VALUE;
\r
183 /* Used by the pseudo random number generator. */
\r
184 static size_t uxNextRand = 0;
\r
186 /* The task handles are stored so their priorities can be changed. */
\r
187 TaskHandle_t xQueueSetSendingTask, xQueueSetReceivingTask;
\r
189 /*-----------------------------------------------------------*/
\r
191 void vStartQueueSetTasks( void )
\r
193 /* Create the tasks. */
\r
194 xTaskCreate( prvQueueSetSendingTask, "SetTx", configMINIMAL_STACK_SIZE, NULL, queuesetMEDIUM_PRIORITY, &xQueueSetSendingTask );
\r
196 if( xQueueSetSendingTask != NULL )
\r
198 xTaskCreate( prvQueueSetReceivingTask, "SetRx", configMINIMAL_STACK_SIZE, ( void * ) xQueueSetSendingTask, queuesetMEDIUM_PRIORITY, &xQueueSetReceivingTask );
\r
200 /* It is important that the sending task does not attempt to write to a
\r
201 queue before the queue has been created. It is therefore placed into
\r
202 the suspended state before the scheduler has started. It is resumed by
\r
203 the receiving task after the receiving task has created the queues and
\r
204 added the queues to the queue set. */
\r
205 vTaskSuspend( xQueueSetSendingTask );
\r
208 /*-----------------------------------------------------------*/
\r
210 BaseType_t xAreQueueSetTasksStillRunning( void )
\r
212 static uint32_t ulLastCycleCounter, ulLastISRTxValue = 0;
\r
213 static uint32_t ulLastQueueUsedCounter[ queuesetNUM_QUEUES_IN_SET ] = { 0 };
\r
214 BaseType_t xReturn = pdPASS, x;
\r
216 if( ulLastCycleCounter == ulCycleCounter )
\r
218 /* The cycle counter is no longer being incremented. Either one of the
\r
219 tasks is stalled or an error has been detected. */
\r
223 ulLastCycleCounter = ulCycleCounter;
\r
225 /* Ensure that all the queues in the set have been used. This ensures the
\r
226 test is working as intended and guards against the rand() in the Tx task
\r
227 missing some values. */
\r
228 for( x = 0; x < queuesetNUM_QUEUES_IN_SET; x++ )
\r
230 if( ulLastQueueUsedCounter[ x ] == ulQueueUsedCounter[ x ] )
\r
235 ulLastQueueUsedCounter[ x ] = ulQueueUsedCounter[ x ];
\r
238 /* Check the global status flag. */
\r
239 if( xQueueSetTasksStatus != pdPASS )
\r
244 /* Check that the ISR is still sending values to the queues too. */
\r
245 if( ulISRTxValue == ulLastISRTxValue )
\r
251 ulLastISRTxValue = ulISRTxValue;
\r
256 /*-----------------------------------------------------------*/
\r
258 static void prvQueueSetSendingTask( void *pvParameters )
\r
260 uint32_t ulTaskTxValue = 0;
\r
261 size_t uxQueueToWriteTo;
\r
262 QueueHandle_t xQueueInUse;
\r
264 /* Remove compiler warning about the unused parameter. */
\r
265 ( void ) pvParameters;
\r
267 /* Seed mini pseudo random number generator. */
\r
268 prvSRand( ( size_t ) &ulTaskTxValue );
\r
272 /* Generate the index for the queue to which a value is to be sent. */
\r
273 uxQueueToWriteTo = prvRand() % queuesetNUM_QUEUES_IN_SET;
\r
274 xQueueInUse = xQueues[ uxQueueToWriteTo ];
\r
276 /* Note which index is being written to to ensure all the queues are
\r
278 ( ulQueueUsedCounter[ uxQueueToWriteTo ] )++;
\r
280 /* Send to the queue to unblock the task that is waiting for data to
\r
281 arrive on a queue within the queue set to which this queue belongs. */
\r
282 if( xQueueSendToBack( xQueueInUse, &ulTaskTxValue, portMAX_DELAY ) != pdPASS )
\r
284 /* The send should always pass as an infinite block time was
\r
286 xQueueSetTasksStatus = pdFAIL;
\r
289 #if( configUSE_PREEMPTION == 0 )
\r
295 /* If the Tx value has reached the range used by the ISR then set it
\r
297 if( ulTaskTxValue == queuesetINITIAL_ISR_TX_VALUE )
\r
302 /* Increase test coverage by occasionally change the priorities of the
\r
303 two tasks relative to each other. */
\r
304 prvChangeRelativePriorities();
\r
307 /*-----------------------------------------------------------*/
\r
309 static void prvChangeRelativePriorities( void )
\r
311 static UBaseType_t ulLoops = 0;
\r
312 static eRelativePriorities ePriorities = eEqualPriority;
\r
314 /* Occasionally change the task priority relative to the priority of
\r
315 the receiving task. */
\r
317 if( ulLoops >= queuesetPRIORITY_CHANGE_LOOPS )
\r
321 switch( ePriorities )
\r
323 case eEqualPriority:
\r
324 /* Both tasks are running with medium priority. Now lower the
\r
325 priority of the receiving task so the Tx task has the higher
\r
326 relative priority. */
\r
327 vTaskPrioritySet( xQueueSetReceivingTask, queuesetLOW_PRIORITY );
\r
328 ePriorities = eTxHigherPriority;
\r
331 case eTxHigherPriority:
\r
332 /* The Tx task is running with a higher priority than the Rx
\r
333 task. Switch the priorities around so the Rx task has the
\r
334 higher relative priority. */
\r
335 vTaskPrioritySet( xQueueSetReceivingTask, queuesetMEDIUM_PRIORITY );
\r
336 vTaskPrioritySet( xQueueSetSendingTask, queuesetLOW_PRIORITY );
\r
337 ePriorities = eTxLowerPriority;
\r
340 case eTxLowerPriority:
\r
341 /* The Tx task is running with a lower priority than the Rx
\r
342 task. Make the priorities equal again. */
\r
343 vTaskPrioritySet( xQueueSetSendingTask, queuesetMEDIUM_PRIORITY );
\r
344 ePriorities = eEqualPriority;
\r
346 /* When both tasks are using a non-idle priority the queue set
\r
347 tasks will starve idle priority tasks of execution time - so
\r
348 relax a bit before the next iteration to minimise the impact. */
\r
349 vTaskDelay( queuesetTX_LOOP_DELAY );
\r
355 /*-----------------------------------------------------------*/
\r
357 static void prvQueueSetReceivingTask( void *pvParameters )
\r
359 uint32_t ulReceived;
\r
360 QueueHandle_t xActivatedQueue;
\r
361 TickType_t xBlockTime;
\r
363 /* Remove compiler warnings. */
\r
364 ( void ) pvParameters;
\r
366 /* Create the queues and add them to the queue set before resuming the Tx
\r
372 /* For test coverage reasons, the block time is dependent on the
\r
373 priority of this task - which changes during the test. When the task
\r
374 is at the idle priority it polls the queue set. */
\r
375 if( uxTaskPriorityGet( NULL ) == tskIDLE_PRIORITY )
\r
381 xBlockTime = portMAX_DELAY;
\r
384 /* Wait for a message to arrive on one of the queues in the set. */
\r
385 xActivatedQueue = xQueueSelectFromSet( xQueueSet, portMAX_DELAY );
\r
387 if( xActivatedQueue == NULL )
\r
389 if( xBlockTime != 0 )
\r
391 /* This should not happen as an infinite delay was used. */
\r
392 xQueueSetTasksStatus = pdFAIL;
\r
397 /* Reading from the queue should pass with a zero block time as
\r
398 this task will only run when something has been posted to a task
\r
399 in the queue set. */
\r
400 if( xQueueReceive( xActivatedQueue, &ulReceived, queuesetDONT_BLOCK ) != pdPASS )
\r
402 xQueueSetTasksStatus = pdFAIL;
\r
405 /* Ensure the value received was the value expected. This function
\r
406 manipulates file scope data and is also called from an ISR, hence
\r
407 the critical section. */
\r
408 taskENTER_CRITICAL();
\r
410 prvCheckReceivedValue( ulReceived );
\r
412 taskEXIT_CRITICAL();
\r
414 if( xQueueSetTasksStatus == pdPASS )
\r
421 /*-----------------------------------------------------------*/
\r
423 void vQueueSetAccessQueueSetFromISR( void )
\r
425 static uint32_t ulCallCount = 0;
\r
427 /* xSetupComplete is set to pdTRUE when the queues have been created and
\r
428 are available for use. */
\r
429 if( xSetupComplete == pdTRUE )
\r
431 /* It is intended that this function is called from the tick hook
\r
432 function, so each call is one tick period apart. */
\r
434 if( ulCallCount > queuesetISR_TX_PERIOD )
\r
438 /* First attempt to read from the queue set. */
\r
439 prvReceiveFromQueueInSetFromISR();
\r
441 /* Then write to the queue set. */
\r
442 prvSendToQueueInSetFromISR();
\r
446 /*-----------------------------------------------------------*/
\r
448 static void prvCheckReceivedValue( uint32_t ulReceived )
\r
450 static uint32_t ulExpectedReceivedFromTask = 0, ulExpectedReceivedFromISR = queuesetINITIAL_ISR_TX_VALUE;
\r
452 /* Values are received in tasks and interrupts. It is likely that the
\r
453 receiving task will sometimes get preempted by the receiving interrupt
\r
454 between reading a value from the queue and calling this function. When
\r
455 that happens, if the receiving interrupt calls this function the values
\r
456 will get passed into this function slightly out of order. For that
\r
457 reason the value passed in is tested against a small range of expected
\r
458 values, rather than a single absolute value. To make the range testing
\r
459 easier values in the range limits are ignored. */
\r
461 /* If the received value is equal to or greater than
\r
462 queuesetINITIAL_ISR_TX_VALUE then it was sent by an ISR. */
\r
463 if( ulReceived >= queuesetINITIAL_ISR_TX_VALUE )
\r
465 /* The value was sent from the ISR. */
\r
466 if( ( ulReceived - queuesetINITIAL_ISR_TX_VALUE ) < queuesetIGNORED_BOUNDARY )
\r
468 /* The value received is at the lower limit of the expected range.
\r
469 Don't test it and expect to receive one higher next time. */
\r
471 else if( ( ULONG_MAX - ulReceived ) <= queuesetIGNORED_BOUNDARY )
\r
473 /* The value received is at the higher limit of the expected range.
\r
474 Don't test it and expect to wrap soon. */
\r
478 /* Check the value against its expected value range. */
\r
479 if( prvCheckReceivedValueWithinExpectedRange( ulReceived, ulExpectedReceivedFromISR ) != pdPASS )
\r
481 xQueueSetTasksStatus = pdFAIL;
\r
485 configASSERT( xQueueSetTasksStatus );
\r
487 /* It is expected to receive an incrementing number. */
\r
488 ulExpectedReceivedFromISR++;
\r
489 if( ulExpectedReceivedFromISR == 0 )
\r
491 ulExpectedReceivedFromISR = queuesetINITIAL_ISR_TX_VALUE;
\r
496 /* The value was sent from the Tx task. */
\r
497 if( ulReceived < queuesetIGNORED_BOUNDARY )
\r
499 /* The value received is at the lower limit of the expected range.
\r
500 Don't test it, and expect to receive one higher next time. */
\r
502 else if( ( ( queuesetINITIAL_ISR_TX_VALUE - 1 ) - ulReceived ) <= queuesetIGNORED_BOUNDARY )
\r
504 /* The value received is at the higher limit of the expected range.
\r
505 Don't test it and expect to wrap soon. */
\r
509 /* Check the value against its expected value range. */
\r
510 if( prvCheckReceivedValueWithinExpectedRange( ulReceived, ulExpectedReceivedFromTask ) != pdPASS )
\r
512 xQueueSetTasksStatus = pdFAIL;
\r
516 configASSERT( xQueueSetTasksStatus );
\r
518 /* It is expected to receive an incrementing number. */
\r
519 ulExpectedReceivedFromTask++;
\r
520 if( ulExpectedReceivedFromTask >= queuesetINITIAL_ISR_TX_VALUE )
\r
522 ulExpectedReceivedFromTask = 0;
\r
526 /*-----------------------------------------------------------*/
\r
528 static BaseType_t prvCheckReceivedValueWithinExpectedRange( uint32_t ulReceived, uint32_t ulExpectedReceived )
\r
530 BaseType_t xReturn = pdPASS;
\r
532 if( ulReceived > ulExpectedReceived )
\r
534 configASSERT( ( ulReceived - ulExpectedReceived ) <= queuesetALLOWABLE_RX_DEVIATION );
\r
535 if( ( ulReceived - ulExpectedReceived ) > queuesetALLOWABLE_RX_DEVIATION )
\r
542 configASSERT( ( ulExpectedReceived - ulReceived ) <= queuesetALLOWABLE_RX_DEVIATION );
\r
543 if( ( ulExpectedReceived - ulReceived ) > queuesetALLOWABLE_RX_DEVIATION )
\r
551 /*-----------------------------------------------------------*/
\r
553 static void prvReceiveFromQueueInSetFromISR( void )
\r
555 QueueSetMemberHandle_t xActivatedQueue;
\r
556 uint32_t ulReceived;
\r
558 /* See if any of the queues in the set contain data. */
\r
559 xActivatedQueue = xQueueSelectFromSetFromISR( xQueueSet );
\r
561 if( xActivatedQueue != NULL )
\r
563 /* Reading from the queue for test purposes only. */
\r
564 if( xQueueReceiveFromISR( xActivatedQueue, &ulReceived, NULL ) != pdPASS )
\r
566 /* Data should have been available as the handle was returned from
\r
567 xQueueSelectFromSetFromISR(). */
\r
568 xQueueSetTasksStatus = pdFAIL;
\r
571 /* Ensure the value received was the value expected. */
\r
572 prvCheckReceivedValue( ulReceived );
\r
575 /*-----------------------------------------------------------*/
\r
577 static void prvSendToQueueInSetFromISR( void )
\r
579 static BaseType_t xQueueToWriteTo = 0;
\r
580 uint32_t ulTxValueSnapshot = ulISRTxValue;
\r
582 if( xQueueSendFromISR( xQueues[ xQueueToWriteTo ], ( void * ) &ulTxValueSnapshot, NULL ) == pdPASS )
\r
586 /* If the Tx value has wrapped then set it back to its initial value. */
\r
587 if( ulISRTxValue == 0UL )
\r
589 ulISRTxValue = queuesetINITIAL_ISR_TX_VALUE;
\r
592 /* Use a different queue next time. */
\r
594 if( xQueueToWriteTo >= queuesetNUM_QUEUES_IN_SET )
\r
596 xQueueToWriteTo = 0;
\r
600 /*-----------------------------------------------------------*/
\r
602 static void prvSetupTest( void )
\r
605 uint32_t ulValueToSend = 0;
\r
607 /* Ensure the queues are created and the queue set configured before the
\r
608 sending task is unsuspended.
\r
610 First Create the queue set such that it will be able to hold a message for
\r
611 every space in every queue in the set. */
\r
612 xQueueSet = xQueueCreateSet( queuesetNUM_QUEUES_IN_SET * queuesetQUEUE_LENGTH );
\r
614 for( x = 0; x < queuesetNUM_QUEUES_IN_SET; x++ )
\r
616 /* Create the queue and add it to the set. The queue is just holding
\r
618 xQueues[ x ] = xQueueCreate( queuesetQUEUE_LENGTH, sizeof( uint32_t ) );
\r
619 configASSERT( xQueues[ x ] );
\r
620 if( xQueueAddToSet( xQueues[ x ], xQueueSet ) != pdPASS )
\r
622 xQueueSetTasksStatus = pdFAIL;
\r
626 /* The queue has now been added to the queue set and cannot be added to
\r
628 if( xQueueAddToSet( xQueues[ x ], xQueueSet ) != pdFAIL )
\r
630 xQueueSetTasksStatus = pdFAIL;
\r
635 /* Attempt to remove a queue from a queue set it does not belong
\r
636 to (NULL being passed as the queue set in this case). */
\r
637 if( xQueueRemoveFromSet( xQueues[ 0 ], NULL ) != pdFAIL )
\r
639 /* It is not possible to successfully remove a queue from a queue
\r
640 set it does not belong to. */
\r
641 xQueueSetTasksStatus = pdFAIL;
\r
644 /* Attempt to remove a queue from the queue set it does belong to. */
\r
645 if( xQueueRemoveFromSet( xQueues[ 0 ], xQueueSet ) != pdPASS )
\r
647 /* It should be possible to remove the queue from the queue set it
\r
649 xQueueSetTasksStatus = pdFAIL;
\r
652 /* Add an item to the queue before attempting to add it back into the
\r
654 xQueueSend( xQueues[ 0 ], ( void * ) &ulValueToSend, 0 );
\r
655 if( xQueueAddToSet( xQueues[ 0 ], xQueueSet ) != pdFAIL )
\r
657 /* Should not be able to add a non-empty queue to a set. */
\r
658 xQueueSetTasksStatus = pdFAIL;
\r
661 /* Remove the item from the queue before adding the queue back into the
\r
662 set so the dynamic tests can begin. */
\r
663 xQueueReceive( xQueues[ 0 ], &ulValueToSend, 0 );
\r
664 if( xQueueAddToSet( xQueues[ 0 ], xQueueSet ) != pdPASS )
\r
666 /* If the queue was successfully removed from the queue set then it
\r
667 should be possible to add it back in again. */
\r
668 xQueueSetTasksStatus = pdFAIL;
\r
671 /* The task that sends to the queues is not running yet, so attempting to
\r
672 read from the queue set should fail. */
\r
673 if( xQueueSelectFromSet( xQueueSet, queuesetSHORT_DELAY ) != NULL )
\r
675 xQueueSetTasksStatus = pdFAIL;
\r
678 /* Resume the task that writes to the queues. */
\r
679 vTaskResume( xQueueSetSendingTask );
\r
681 /* Let the ISR access the queues also. */
\r
682 xSetupComplete = pdTRUE;
\r
684 /*-----------------------------------------------------------*/
\r
686 static size_t prvRand( void )
\r
688 uxNextRand = ( uxNextRand * ( size_t ) 1103515245 ) + ( size_t ) 12345;
\r
689 return ( uxNextRand / ( size_t ) 65536 ) % ( size_t ) 32768;
\r
691 /*-----------------------------------------------------------*/
\r
693 static void prvSRand( size_t uxSeed )
\r
695 uxNextRand = uxSeed;
\r