2 FreeRTOS V7.5.2 - Copyright (C) 2013 Real Time Engineers Ltd.
\r
4 VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
\r
6 ***************************************************************************
\r
8 * FreeRTOS provides completely free yet professionally developed, *
\r
9 * robust, strictly quality controlled, supported, and cross *
\r
10 * platform software that has become a de facto standard. *
\r
12 * Help yourself get started quickly and support the FreeRTOS *
\r
13 * project by purchasing a FreeRTOS tutorial book, reference *
\r
14 * manual, or both from: http://www.FreeRTOS.org/Documentation *
\r
18 ***************************************************************************
\r
20 This file is part of the FreeRTOS distribution.
\r
22 FreeRTOS is free software; you can redistribute it and/or modify it under
\r
23 the terms of the GNU General Public License (version 2) as published by the
\r
24 Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.
\r
26 >>! NOTE: The modification to the GPL is included to allow you to distribute
\r
27 >>! a combined work that includes FreeRTOS without being obliged to provide
\r
28 >>! the source code for proprietary components outside of the FreeRTOS
\r
31 FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
\r
32 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
\r
33 FOR A PARTICULAR PURPOSE. Full license text is available from the following
\r
34 link: http://www.freertos.org/a00114.html
\r
38 ***************************************************************************
\r
40 * Having a problem? Start by reading the FAQ "My application does *
\r
41 * not run, what could be wrong?" *
\r
43 * http://www.FreeRTOS.org/FAQHelp.html *
\r
45 ***************************************************************************
\r
47 http://www.FreeRTOS.org - Documentation, books, training, latest versions,
\r
48 license and Real Time Engineers Ltd. contact details.
\r
50 http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
\r
51 including FreeRTOS+Trace - an indispensable productivity tool, a DOS
\r
52 compatible FAT file system, and our tiny thread aware UDP/IP stack.
\r
54 http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High
\r
55 Integrity Systems to sell under the OpenRTOS brand. Low cost OpenRTOS
\r
56 licenses offer ticketed support, indemnification and middleware.
\r
58 http://www.SafeRTOS.com - High Integrity Systems also provide a safety
\r
59 engineered and independently SIL3 certified version for use in safety and
\r
60 mission critical applications that require provable dependability.
\r
66 * Tests the use of queue sets.
\r
68 * A receive task creates a number of queues and adds them to a queue set before
\r
69 * blocking on the queue set receive. A transmit task and (optionally) an
\r
70 * interrupt repeatedly unblocks the receive task by sending messages to the
\r
71 * queues in a pseudo random order. The receive task removes the messages from
\r
72 * the queues and flags an error if the received message does not match that
\r
73 * expected. The task sends values in the range 0 to
\r
74 * queuesetINITIAL_ISR_TX_VALUE, and the ISR sends value in the range
\r
75 * queuesetINITIAL_ISR_TX_VALUE to ULONG_MAX.
\r
78 /* Standard includes. */
\r
82 /* Kernel includes. */
\r
83 #include "FreeRTOS.h"
\r
87 /* Demo includes. */
\r
88 #include "QueueSet.h"
\r
90 /* The number of queues that are created and added to the queue set. */
\r
91 #define queuesetNUM_QUEUES_IN_SET 3
\r
93 /* The length of each created queue. */
\r
94 #define queuesetQUEUE_LENGTH 3
\r
96 /* Block times used in this demo. A block time or 0 means "don't block". */
\r
97 #define queuesetSHORT_DELAY 200
\r
98 #define queuesetDONT_BLOCK 0
\r
100 /* Messages are sent in incrementing order from both a task and an interrupt.
\r
101 The task sends values in the range 0 to 0xfffe, and the interrupt sends values
\r
102 in the range of 0xffff to ULONG_MAX. */
\r
103 #define queuesetINITIAL_ISR_TX_VALUE 0xffffUL
\r
105 /* The priorities used in this demo. */
\r
106 #define queuesetLOW_PRIORITY ( tskIDLE_PRIORITY )
\r
107 #define queuesetMEDIUM_PRIORITY ( queuesetLOW_PRIORITY + 1 )
\r
108 #define queuesetHIGH_PRIORITY ( queuesetMEDIUM_PRIORITY + 1 )
\r
110 /* For test purposes the priority of the sending task is changed after every
\r
111 queuesetPRIORITY_CHANGE_LOOPS number of values are sent to a queue. */
\r
112 #define queuesetPRIORITY_CHANGE_LOOPS ( ( queuesetNUM_QUEUES_IN_SET * queuesetQUEUE_LENGTH ) * 2 )
\r
114 /* The ISR sends to the queue every queuesetISR_TX_PERIOD ticks. */
\r
115 #define queuesetISR_TX_PERIOD ( 100UL )
\r
117 /* A delay inserted when the Tx task changes its priority to be above the idle
\r
118 task priority to ensure the idle priority tasks get some CPU time before the
\r
119 next iteration of the queue set Tx task. */
\r
120 #define queuesetTX_LOOP_DELAY ( 200 / portTICK_RATE_MS )
\r
122 /* The allowable maximum deviation between a received value and the expected
\r
123 received value. A deviation will occur when data is received from a queue
\r
124 inside an ISR in between a task receiving from a queue and the task checking
\r
125 the received value. */
\r
126 #define queuesetALLOWABLE_RX_DEVIATION 3
\r
128 /* Ignore values that are at the boundaries of allowable values to make the
\r
129 testing of limits easier (don't have to deal with wrapping values). */
\r
130 #define queuesetIGNORED_BOUNDARY ( queuesetALLOWABLE_RX_DEVIATION * 2 )
\r
134 eEqualPriority = 0, /* Tx and Rx tasks have the same priority. */
\r
135 eTxHigherPriority, /* The priority of the Tx task is above that of the Rx task. */
\r
136 eTxLowerPriority /* The priority of the Tx task is below that of the Rx task. */
\r
137 } eRelativePriorities;
\r
140 * The task that periodically sends to the queue set.
\r
142 static void prvQueueSetSendingTask( void *pvParameters );
\r
145 * The task that reads from the queue set.
\r
147 static void prvQueueSetReceivingTask( void *pvParameters );
\r
150 * Check the value received from a queue is the expected value. Some values
\r
151 * originate from the send task, some values originate from the ISR, with the
\r
152 * range of the value being used to distinguish between the two message
\r
155 static void prvCheckReceivedValue( unsigned long ulReceived );
\r
158 * For purposes of test coverage, functions that read from and write to a
\r
159 * queue set from an ISR respectively.
\r
161 static void prvReceiveFromQueueInSetFromISR( void );
\r
162 static void prvSendToQueueInSetFromISR( void );
\r
165 * Create the queues and add them to a queue set before resuming the Tx
\r
168 static void prvSetupTest( xTaskHandle xQueueSetSendingTask );
\r
171 * Checks a value received from a queue falls within the range of expected
\r
174 static portBASE_TYPE prvCheckReceivedValueWithinExpectedRange( unsigned long ulReceived, unsigned long ulExpectedReceived );
\r
177 * Increase test coverage by occasionally change the priorities of the two tasks
\r
178 * relative to each other. */
\r
179 static void prvChangeRelativePriorities( void );
\r
182 * Local pseudo random number seed and return functions. Used to avoid calls
\r
183 * to the standard library.
\r
185 static unsigned long prvRand( void );
\r
186 static void prvSRand( unsigned long ulSeed );
\r
188 /*-----------------------------------------------------------*/
\r
190 /* The queues that are added to the set. */
\r
191 static xQueueHandle xQueues[ queuesetNUM_QUEUES_IN_SET ] = { 0 };
\r
193 /* Counts how many times each queue in the set is used to ensure all the
\r
194 queues are used. */
\r
195 static unsigned long ulQueueUsedCounter[ queuesetNUM_QUEUES_IN_SET ] = { 0 };
\r
197 /* The handle of the queue set to which the queues are added. */
\r
198 static xQueueSetHandle xQueueSet;
\r
200 /* If the prvQueueSetReceivingTask() task has not detected any errors then
\r
201 it increments ulCycleCounter on each iteration.
\r
202 xAreQueueSetTasksStillRunning() returns pdPASS if the value of
\r
203 ulCycleCounter has changed between consecutive calls, and pdFALSE if
\r
204 ulCycleCounter has stopped incrementing (indicating an error condition). */
\r
205 static volatile unsigned long ulCycleCounter = 0UL;
\r
207 /* Set to pdFAIL if an error is detected by any queue set task.
\r
208 ulCycleCounter will only be incremented if xQueueSetTasksSatus equals pdPASS. */
\r
209 static volatile portBASE_TYPE xQueueSetTasksStatus = pdPASS;
\r
211 /* Just a flag to let the function that writes to a queue from an ISR know that
\r
212 the queues are setup and can be used. */
\r
213 static volatile portBASE_TYPE xSetupComplete = pdFALSE;
\r
215 /* The value sent to the queue from the ISR is file scope so the
\r
216 xAreQueeuSetTasksStillRunning() function can check it is incrementing as
\r
218 static volatile unsigned long ulISRTxValue = queuesetINITIAL_ISR_TX_VALUE;
\r
220 /* Used by the pseudo random number generator. */
\r
221 static unsigned long ulNextRand = 0;
\r
223 /* The task handles are stored so their priorities can be changed. */
\r
224 xTaskHandle xQueueSetSendingTask, xQueueSetReceivingTask;
\r
226 /*-----------------------------------------------------------*/
\r
228 void vStartQueueSetTasks( void )
\r
230 /* Create the two queues. The handle of the sending task is passed into
\r
231 the receiving task using the task parameter. The receiving task uses the
\r
232 handle to resume the sending task after it has created the queues. */
\r
233 xTaskCreate( prvQueueSetSendingTask, ( signed char * ) "SetTx", configMINIMAL_STACK_SIZE, NULL, queuesetMEDIUM_PRIORITY, &xQueueSetSendingTask );
\r
234 xTaskCreate( prvQueueSetReceivingTask, ( signed char * ) "SetRx", configMINIMAL_STACK_SIZE, ( void * ) xQueueSetSendingTask, queuesetMEDIUM_PRIORITY, &xQueueSetReceivingTask );
\r
236 /* It is important that the sending task does not attempt to write to a
\r
237 queue before the queue has been created. It is therefore placed into the
\r
238 suspended state before the scheduler has started. It is resumed by the
\r
239 receiving task after the receiving task has created the queues and added the
\r
240 queues to the queue set. */
\r
241 vTaskSuspend( xQueueSetSendingTask );
\r
243 /*-----------------------------------------------------------*/
\r
245 portBASE_TYPE xAreQueueSetTasksStillRunning( void )
\r
247 static unsigned long ulLastCycleCounter, ulLastISRTxValue = 0;
\r
248 static unsigned long ulLastQueueUsedCounter[ queuesetNUM_QUEUES_IN_SET ] = { 0 };
\r
249 portBASE_TYPE xReturn = pdPASS, x;
\r
251 if( ulLastCycleCounter == ulCycleCounter )
\r
253 /* The cycle counter is no longer being incremented. Either one of the
\r
254 tasks is stalled or an error has been detected. */
\r
258 ulLastCycleCounter = ulCycleCounter;
\r
260 /* Ensure that all the queues in the set have been used. This ensures the
\r
261 test is working as intended and guards against the rand() in the Tx task
\r
262 missing some values. */
\r
263 for( x = 0; x < queuesetNUM_QUEUES_IN_SET; x++ )
\r
265 if( ulLastQueueUsedCounter[ x ] == ulQueueUsedCounter[ x ] )
\r
270 ulLastQueueUsedCounter[ x ] = ulQueueUsedCounter[ x ];
\r
273 /* Check the global status flag. */
\r
274 if( xQueueSetTasksStatus != pdPASS )
\r
279 /* Check that the ISR is still sending values to the queues too. */
\r
280 if( ulISRTxValue == ulLastISRTxValue )
\r
286 ulLastISRTxValue = ulISRTxValue;
\r
291 /*-----------------------------------------------------------*/
\r
293 static void prvQueueSetSendingTask( void *pvParameters )
\r
295 unsigned long ulTaskTxValue = 0, ulQueueToWriteTo;
\r
296 xQueueHandle xQueueInUse;
\r
298 /* Remove compiler warning about the unused parameter. */
\r
299 ( void ) pvParameters;
\r
301 /* Seed mini pseudo random number generator. */
\r
302 prvSRand( ( unsigned long ) &ulTaskTxValue );
\r
306 /* Generate the index for the queue to which a value is to be sent. */
\r
307 ulQueueToWriteTo = prvRand() % queuesetNUM_QUEUES_IN_SET;
\r
308 xQueueInUse = xQueues[ ulQueueToWriteTo ];
\r
310 /* Note which index is being written to to ensure all the queues are
\r
312 ( ulQueueUsedCounter[ ulQueueToWriteTo ] )++;
\r
314 /* Send to the queue to unblock the task that is waiting for data to
\r
315 arrive on a queue within the queue set to which this queue belongs. */
\r
316 if( xQueueSendToBack( xQueueInUse, &ulTaskTxValue, portMAX_DELAY ) != pdPASS )
\r
318 /* The send should always pass as an infinite block time was
\r
320 xQueueSetTasksStatus = pdFAIL;
\r
325 /* If the Tx value has reached the range used by the ISR then set it
\r
327 if( ulTaskTxValue == queuesetINITIAL_ISR_TX_VALUE )
\r
332 /* Increase test coverage by occasionally change the priorities of the
\r
333 two tasks relative to each other. */
\r
334 prvChangeRelativePriorities();
\r
337 /*-----------------------------------------------------------*/
\r
339 static void prvChangeRelativePriorities( void )
\r
341 static unsigned portBASE_TYPE ulLoops = 0;
\r
342 static eRelativePriorities ePriorities = eEqualPriority;
\r
344 /* Occasionally change the task priority relative to the priority of
\r
345 the receiving task. */
\r
347 if( ulLoops >= queuesetPRIORITY_CHANGE_LOOPS )
\r
351 switch( ePriorities )
\r
353 case eEqualPriority:
\r
354 /* Both tasks are running with medium priority. Now lower the
\r
355 priority of the receiving task so the Tx task has the higher
\r
356 relative priority. */
\r
357 vTaskPrioritySet( xQueueSetReceivingTask, queuesetLOW_PRIORITY );
\r
358 ePriorities = eTxHigherPriority;
\r
361 case eTxHigherPriority:
\r
362 /* The Tx task is running with a higher priority than the Rx
\r
363 task. Switch the priorities around so the Rx task has the
\r
364 higher relative priority. */
\r
365 vTaskPrioritySet( xQueueSetReceivingTask, queuesetMEDIUM_PRIORITY );
\r
366 vTaskPrioritySet( xQueueSetSendingTask, queuesetLOW_PRIORITY );
\r
367 ePriorities = eTxLowerPriority;
\r
370 case eTxLowerPriority:
\r
371 /* The Tx task is running with a lower priority than the Rx
\r
372 task. Make the priorities equal again. */
\r
373 vTaskPrioritySet( xQueueSetSendingTask, queuesetMEDIUM_PRIORITY );
\r
374 ePriorities = eEqualPriority;
\r
376 /* When both tasks are using a non-idle priority the queue set
\r
377 tasks will starve idle priority tasks of execution time - so
\r
378 relax a bit before the next iteration to minimise the impact. */
\r
379 vTaskDelay( queuesetTX_LOOP_DELAY );
\r
385 /*-----------------------------------------------------------*/
\r
387 static void prvQueueSetReceivingTask( void *pvParameters )
\r
389 unsigned long ulReceived;
\r
390 xQueueHandle xActivatedQueue;
\r
391 xTaskHandle xQueueSetSendingTask;
\r
393 /* The handle to the sending task is passed in using the task parameter. */
\r
394 xQueueSetSendingTask = ( xTaskHandle ) pvParameters;
\r
396 /* Create the queues and add them to the queue set before resuming the Tx
\r
398 prvSetupTest( xQueueSetSendingTask );
\r
402 /* Wait for a message to arrive on one of the queues in the set. */
\r
403 xActivatedQueue = xQueueSelectFromSet( xQueueSet, portMAX_DELAY );
\r
404 configASSERT( xActivatedQueue );
\r
406 if( xActivatedQueue == NULL )
\r
408 /* This should not happen as an infinite delay was used. */
\r
409 xQueueSetTasksStatus = pdFAIL;
\r
413 /* Reading from the queue should pass with a zero block time as
\r
414 this task will only run when something has been posted to a task
\r
415 in the queue set. */
\r
416 if( xQueueReceive( xActivatedQueue, &ulReceived, queuesetDONT_BLOCK ) != pdPASS )
\r
418 xQueueSetTasksStatus = pdFAIL;
\r
421 /* Ensure the value received was the value expected. This function
\r
422 manipulates file scope data and is also called from an ISR, hence
\r
423 the critical section. */
\r
424 taskENTER_CRITICAL();
\r
426 prvCheckReceivedValue( ulReceived );
\r
428 taskEXIT_CRITICAL();
\r
431 if( xQueueSetTasksStatus == pdPASS )
\r
437 /*-----------------------------------------------------------*/
\r
439 void vQueueSetAccessQueueSetFromISR( void )
\r
441 static unsigned long ulCallCount = 0;
\r
443 /* xSetupComplete is set to pdTRUE when the queues have been created and
\r
444 are available for use. */
\r
445 if( xSetupComplete == pdTRUE )
\r
447 /* It is intended that this function is called from the tick hook
\r
448 function, so each call is one tick period apart. */
\r
450 if( ulCallCount > queuesetISR_TX_PERIOD )
\r
454 /* First attempt to read from the queue set. */
\r
455 prvReceiveFromQueueInSetFromISR();
\r
457 /* Then write to the queue set. */
\r
458 prvSendToQueueInSetFromISR();
\r
462 /*-----------------------------------------------------------*/
\r
464 static void prvCheckReceivedValue( unsigned long ulReceived )
\r
466 static unsigned long ulExpectedReceivedFromTask = 0, ulExpectedReceivedFromISR = queuesetINITIAL_ISR_TX_VALUE;
\r
468 /* Values are received in tasks and interrupts. It is likely that the
\r
469 receiving task will sometimes get preempted by the receiving interrupt
\r
470 between reading a value from the queue and calling this function. When
\r
471 that happens, if the receiving interrupt calls this function the values
\r
472 will get passed into this function slightly out of order. For that
\r
473 reason the value passed in is tested against a small range of expected
\r
474 values, rather than a single absolute value. To make the range testing
\r
475 easier values in the range limits are ignored. */
\r
477 /* If the received value is equal to or greater than
\r
478 queuesetINITIAL_ISR_TX_VALUE then it was sent by an ISR. */
\r
479 if( ulReceived >= queuesetINITIAL_ISR_TX_VALUE )
\r
481 /* The value was sent from the ISR. */
\r
482 if( ( ulReceived - queuesetINITIAL_ISR_TX_VALUE ) < queuesetIGNORED_BOUNDARY )
\r
484 /* The value received is at the lower limit of the expected range.
\r
485 Don't test it and expect to receive one higher next time. */
\r
486 ulExpectedReceivedFromISR++;
\r
488 else if( ( ULONG_MAX - ulReceived ) <= queuesetIGNORED_BOUNDARY )
\r
490 /* The value received is at the higher limit of the expected range.
\r
491 Don't test it and expect to wrap soon. */
\r
492 ulExpectedReceivedFromISR++;
\r
493 if( ulExpectedReceivedFromISR == 0 )
\r
495 ulExpectedReceivedFromISR = queuesetINITIAL_ISR_TX_VALUE;
\r
500 /* Check the value against its expected value range. */
\r
501 if( prvCheckReceivedValueWithinExpectedRange( ulReceived, ulExpectedReceivedFromISR ) != pdPASS )
\r
503 xQueueSetTasksStatus = pdFAIL;
\r
507 /* It is expected to receive an incrementing value. */
\r
508 ulExpectedReceivedFromISR++;
\r
514 /* The value was sent from the Tx task. */
\r
515 if( ulReceived < queuesetIGNORED_BOUNDARY )
\r
517 /* The value received is at the lower limit of the expected range.
\r
518 Don't test it, and expect to receive one higher next time. */
\r
519 ulExpectedReceivedFromTask++;
\r
521 else if( ( ( queuesetINITIAL_ISR_TX_VALUE - 1 ) - ulReceived ) <= queuesetIGNORED_BOUNDARY )
\r
523 /* The value received is at the higher limit of the expected range.
\r
524 Don't test it and expect to wrap soon. */
\r
525 ulExpectedReceivedFromTask++;
\r
526 if( ulExpectedReceivedFromTask >= queuesetINITIAL_ISR_TX_VALUE )
\r
528 ulExpectedReceivedFromTask = 0;
\r
533 /* Check the value against its expected value range. */
\r
534 if( prvCheckReceivedValueWithinExpectedRange( ulReceived, ulExpectedReceivedFromTask ) != pdPASS )
\r
536 xQueueSetTasksStatus = pdFAIL;
\r
540 /* It is expected to receive an incrementing value. */
\r
541 ulExpectedReceivedFromTask++;
\r
546 /*-----------------------------------------------------------*/
\r
548 static portBASE_TYPE prvCheckReceivedValueWithinExpectedRange( unsigned long ulReceived, unsigned long ulExpectedReceived )
\r
550 portBASE_TYPE xReturn = pdPASS;
\r
552 if( ulReceived > ulExpectedReceived )
\r
554 configASSERT( ( ulReceived - ulExpectedReceived ) <= queuesetALLOWABLE_RX_DEVIATION );
\r
555 if( ( ulReceived - ulExpectedReceived ) > queuesetALLOWABLE_RX_DEVIATION )
\r
562 configASSERT( ( ulExpectedReceived - ulReceived ) <= queuesetALLOWABLE_RX_DEVIATION );
\r
563 if( ( ulExpectedReceived - ulReceived ) > queuesetALLOWABLE_RX_DEVIATION )
\r
571 /*-----------------------------------------------------------*/
\r
573 static void prvReceiveFromQueueInSetFromISR( void )
\r
575 xQueueSetMemberHandle xActivatedQueue;
\r
576 unsigned long ulReceived;
\r
578 /* See if any of the queues in the set contain data. */
\r
579 xActivatedQueue = xQueueSelectFromSetFromISR( xQueueSet );
\r
581 if( xActivatedQueue != NULL )
\r
583 /* Reading from the queue for test purposes only. */
\r
584 if( xQueueReceiveFromISR( xActivatedQueue, &ulReceived, NULL ) != pdPASS )
\r
586 /* Data should have been available as the handle was returned from
\r
587 xQueueSelectFromSetFromISR(). */
\r
588 xQueueSetTasksStatus = pdFAIL;
\r
591 /* Ensure the value received was the value expected. */
\r
592 prvCheckReceivedValue( ulReceived );
\r
595 /*-----------------------------------------------------------*/
\r
597 static void prvSendToQueueInSetFromISR( void )
\r
599 static portBASE_TYPE xQueueToWriteTo = 0;
\r
601 if( xQueueSendFromISR( xQueues[ xQueueToWriteTo ], ( void * ) &ulISRTxValue, NULL ) == pdPASS )
\r
605 /* If the Tx value has wrapped then set it back to its
\r
607 if( ulISRTxValue == 0UL )
\r
609 ulISRTxValue = queuesetINITIAL_ISR_TX_VALUE;
\r
612 /* Use a different queue next time. */
\r
614 if( xQueueToWriteTo >= queuesetNUM_QUEUES_IN_SET )
\r
616 xQueueToWriteTo = 0;
\r
620 /*-----------------------------------------------------------*/
\r
622 static void prvSetupTest( xTaskHandle xQueueSetSendingTask )
\r
625 unsigned long ulValueToSend = 0;
\r
627 /* Ensure the queues are created and the queue set configured before the
\r
628 sending task is unsuspended.
\r
630 First Create the queue set such that it will be able to hold a message for
\r
631 every space in every queue in the set. */
\r
632 xQueueSet = xQueueCreateSet( queuesetNUM_QUEUES_IN_SET * queuesetQUEUE_LENGTH );
\r
634 for( x = 0; x < queuesetNUM_QUEUES_IN_SET; x++ )
\r
636 /* Create the queue and add it to the set. The queue is just holding
\r
637 unsigned long value. */
\r
638 xQueues[ x ] = xQueueCreate( queuesetQUEUE_LENGTH, sizeof( unsigned long ) );
\r
639 configASSERT( xQueues[ x ] );
\r
640 if( xQueueAddToSet( xQueues[ x ], xQueueSet ) != pdPASS )
\r
642 xQueueSetTasksStatus = pdFAIL;
\r
646 /* The queue has now been added to the queue set and cannot be added to
\r
648 if( xQueueAddToSet( xQueues[ x ], xQueueSet ) != pdFAIL )
\r
650 xQueueSetTasksStatus = pdFAIL;
\r
655 /* Attempt to remove a queue from a queue set it does not belong
\r
656 to (NULL being passed as the queue set in this case). */
\r
657 if( xQueueRemoveFromSet( xQueues[ 0 ], NULL ) != pdFAIL )
\r
659 /* It is not possible to successfully remove a queue from a queue
\r
660 set it does not belong to. */
\r
661 xQueueSetTasksStatus = pdFAIL;
\r
664 /* Attempt to remove a queue from the queue set it does belong to. */
\r
665 if( xQueueRemoveFromSet( xQueues[ 0 ], xQueueSet ) != pdPASS )
\r
667 /* It should be possible to remove the queue from the queue set it
\r
669 xQueueSetTasksStatus = pdFAIL;
\r
672 /* Add an item to the queue before attempting to add it back into the
\r
674 xQueueSend( xQueues[ 0 ], ( void * ) &ulValueToSend, 0 );
\r
675 if( xQueueAddToSet( xQueues[ 0 ], xQueueSet ) != pdFAIL )
\r
677 /* Should not be able to add a non-empty queue to a set. */
\r
678 xQueueSetTasksStatus = pdFAIL;
\r
681 /* Remove the item from the queue before adding the queue back into the
\r
682 set so the dynamic tests can begin. */
\r
683 xQueueReceive( xQueues[ 0 ], &ulValueToSend, 0 );
\r
684 if( xQueueAddToSet( xQueues[ 0 ], xQueueSet ) != pdPASS )
\r
686 /* If the queue was successfully removed from the queue set then it
\r
687 should be possible to add it back in again. */
\r
688 xQueueSetTasksStatus = pdFAIL;
\r
691 /* The task that sends to the queues is not running yet, so attempting to
\r
692 read from the queue set should fail. */
\r
693 if( xQueueSelectFromSet( xQueueSet, queuesetSHORT_DELAY ) != NULL )
\r
695 xQueueSetTasksStatus = pdFAIL;
\r
698 /* Resume the task that writes to the queues. */
\r
699 vTaskResume( xQueueSetSendingTask );
\r
701 /* Let the ISR access the queues also. */
\r
702 xSetupComplete = pdTRUE;
\r
704 /*-----------------------------------------------------------*/
\r
706 static unsigned long prvRand( void )
\r
708 ulNextRand = ( ulNextRand * 1103515245UL ) + 12345UL;
\r
709 return (ulNextRand / 65536UL ) % 32768UL;
\r
711 /*-----------------------------------------------------------*/
\r
713 static void prvSRand( unsigned long ulSeed )
\r
715 ulNextRand = ulSeed;
\r