2 FreeRTOS V7.5.3 - Copyright (C) 2013 Real Time Engineers Ltd.
\r
5 VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
\r
7 ***************************************************************************
\r
9 * FreeRTOS provides completely free yet professionally developed, *
\r
10 * robust, strictly quality controlled, supported, and cross *
\r
11 * platform software that has become a de facto standard. *
\r
13 * Help yourself get started quickly and support the FreeRTOS *
\r
14 * project by purchasing a FreeRTOS tutorial book, reference *
\r
15 * manual, or both from: http://www.FreeRTOS.org/Documentation *
\r
19 ***************************************************************************
\r
21 This file is part of the FreeRTOS distribution.
\r
23 FreeRTOS is free software; you can redistribute it and/or modify it under
\r
24 the terms of the GNU General Public License (version 2) as published by the
\r
25 Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.
\r
27 >>! NOTE: The modification to the GPL is included to allow you to distribute
\r
28 >>! a combined work that includes FreeRTOS without being obliged to provide
\r
29 >>! the source code for proprietary components outside of the FreeRTOS
\r
32 FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
\r
33 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
\r
34 FOR A PARTICULAR PURPOSE. Full license text is available from the following
\r
35 link: http://www.freertos.org/a00114.html
\r
39 ***************************************************************************
\r
41 * Having a problem? Start by reading the FAQ "My application does *
\r
42 * not run, what could be wrong?" *
\r
44 * http://www.FreeRTOS.org/FAQHelp.html *
\r
46 ***************************************************************************
\r
48 http://www.FreeRTOS.org - Documentation, books, training, latest versions,
\r
49 license and Real Time Engineers Ltd. contact details.
\r
51 http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
\r
52 including FreeRTOS+Trace - an indispensable productivity tool, a DOS
\r
53 compatible FAT file system, and our tiny thread aware UDP/IP stack.
\r
55 http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High
\r
56 Integrity Systems to sell under the OpenRTOS brand. Low cost OpenRTOS
\r
57 licenses offer ticketed support, indemnification and middleware.
\r
59 http://www.SafeRTOS.com - High Integrity Systems also provide a safety
\r
60 engineered and independently SIL3 certified version for use in safety and
\r
61 mission critical applications that require provable dependability.
\r
67 * Tests the use of queue sets.
\r
69 * A receive task creates a number of queues and adds them to a queue set before
\r
70 * blocking on the queue set receive. A transmit task and (optionally) an
\r
71 * interrupt repeatedly unblocks the receive task by sending messages to the
\r
72 * queues in a pseudo random order. The receive task removes the messages from
\r
73 * the queues and flags an error if the received message does not match that
\r
74 * expected. The task sends values in the range 0 to
\r
75 * queuesetINITIAL_ISR_TX_VALUE, and the ISR sends value in the range
\r
76 * queuesetINITIAL_ISR_TX_VALUE to ULONG_MAX.
\r
80 /* Standard includes. */
\r
84 /* Kernel includes. */
\r
85 #include "FreeRTOS.h"
\r
89 /* Demo includes. */
\r
90 #include "QueueSet.h"
\r
92 /* The number of queues that are created and added to the queue set. */
\r
93 #define queuesetNUM_QUEUES_IN_SET 3
\r
95 /* The length of each created queue. */
\r
96 #define queuesetQUEUE_LENGTH 3
\r
98 /* Block times used in this demo. A block time or 0 means "don't block". */
\r
99 #define queuesetSHORT_DELAY 200
\r
100 #define queuesetDONT_BLOCK 0
\r
102 /* Messages are sent in incrementing order from both a task and an interrupt.
\r
103 The task sends values in the range 0 to 0xfffe, and the interrupt sends values
\r
104 in the range of 0xffff to ULONG_MAX. */
\r
105 #define queuesetINITIAL_ISR_TX_VALUE 0xffffUL
\r
107 /* The priorities used in this demo. */
\r
108 #define queuesetLOW_PRIORITY ( tskIDLE_PRIORITY )
\r
109 #define queuesetMEDIUM_PRIORITY ( queuesetLOW_PRIORITY + 1 )
\r
111 /* For test purposes the priority of the sending task is changed after every
\r
112 queuesetPRIORITY_CHANGE_LOOPS number of values are sent to a queue. */
\r
113 #define queuesetPRIORITY_CHANGE_LOOPS ( ( queuesetNUM_QUEUES_IN_SET * queuesetQUEUE_LENGTH ) * 2 )
\r
115 /* The ISR sends to the queue every queuesetISR_TX_PERIOD ticks. */
\r
116 #define queuesetISR_TX_PERIOD ( 100UL )
\r
118 /* A delay inserted when the Tx task changes its priority to be above the idle
\r
119 task priority to ensure the idle priority tasks get some CPU time before the
\r
120 next iteration of the queue set Tx task. */
\r
121 #define queuesetTX_LOOP_DELAY ( 200 / portTICK_RATE_MS )
\r
123 /* The allowable maximum deviation between a received value and the expected
\r
124 received value. A deviation will occur when data is received from a queue
\r
125 inside an ISR in between a task receiving from a queue and the task checking
\r
126 the received value. */
\r
127 #define queuesetALLOWABLE_RX_DEVIATION 3
\r
129 /* Ignore values that are at the boundaries of allowable values to make the
\r
130 testing of limits easier (don't have to deal with wrapping values). */
\r
131 #define queuesetIGNORED_BOUNDARY ( queuesetALLOWABLE_RX_DEVIATION * 2 )
\r
135 eEqualPriority = 0, /* Tx and Rx tasks have the same priority. */
\r
136 eTxHigherPriority, /* The priority of the Tx task is above that of the Rx task. */
\r
137 eTxLowerPriority /* The priority of the Tx task is below that of the Rx task. */
\r
138 } eRelativePriorities;
\r
141 * The task that periodically sends to the queue set.
\r
143 static void prvQueueSetSendingTask( void *pvParameters );
\r
146 * The task that reads from the queue set.
\r
148 static void prvQueueSetReceivingTask( void *pvParameters );
\r
151 * Check the value received from a queue is the expected value. Some values
\r
152 * originate from the send task, some values originate from the ISR, with the
\r
153 * range of the value being used to distinguish between the two message
\r
156 static void prvCheckReceivedValue( unsigned long ulReceived );
\r
159 * For purposes of test coverage, functions that read from and write to a
\r
160 * queue set from an ISR respectively.
\r
162 static void prvReceiveFromQueueInSetFromISR( void );
\r
163 static void prvSendToQueueInSetFromISR( void );
\r
166 * Create the queues and add them to a queue set before resuming the Tx
\r
169 static void prvSetupTest( void );
\r
172 * Checks a value received from a queue falls within the range of expected
\r
175 static portBASE_TYPE prvCheckReceivedValueWithinExpectedRange( unsigned long ulReceived, unsigned long ulExpectedReceived );
\r
178 * Increase test coverage by occasionally change the priorities of the two tasks
\r
179 * relative to each other. */
\r
180 static void prvChangeRelativePriorities( void );
\r
183 * Local pseudo random number seed and return functions. Used to avoid calls
\r
184 * to the standard library.
\r
186 static unsigned long prvRand( void );
\r
187 static void prvSRand( unsigned long ulSeed );
\r
189 /*-----------------------------------------------------------*/
\r
191 /* The queues that are added to the set. */
\r
192 static xQueueHandle xQueues[ queuesetNUM_QUEUES_IN_SET ] = { 0 };
\r
194 /* Counts how many times each queue in the set is used to ensure all the
\r
195 queues are used. */
\r
196 static unsigned long ulQueueUsedCounter[ queuesetNUM_QUEUES_IN_SET ] = { 0 };
\r
198 /* The handle of the queue set to which the queues are added. */
\r
199 static xQueueSetHandle xQueueSet;
\r
201 /* If the prvQueueSetReceivingTask() task has not detected any errors then
\r
202 it increments ulCycleCounter on each iteration.
\r
203 xAreQueueSetTasksStillRunning() returns pdPASS if the value of
\r
204 ulCycleCounter has changed between consecutive calls, and pdFALSE if
\r
205 ulCycleCounter has stopped incrementing (indicating an error condition). */
\r
206 static volatile unsigned long ulCycleCounter = 0UL;
\r
208 /* Set to pdFAIL if an error is detected by any queue set task.
\r
209 ulCycleCounter will only be incremented if xQueueSetTasksSatus equals pdPASS. */
\r
210 static volatile portBASE_TYPE xQueueSetTasksStatus = pdPASS;
\r
212 /* Just a flag to let the function that writes to a queue from an ISR know that
\r
213 the queues are setup and can be used. */
\r
214 static volatile portBASE_TYPE xSetupComplete = pdFALSE;
\r
216 /* The value sent to the queue from the ISR is file scope so the
\r
217 xAreQueeuSetTasksStillRunning() function can check it is incrementing as
\r
219 static volatile unsigned long ulISRTxValue = queuesetINITIAL_ISR_TX_VALUE;
\r
221 /* Used by the pseudo random number generator. */
\r
222 static unsigned long ulNextRand = 0;
\r
224 /* The task handles are stored so their priorities can be changed. */
\r
225 xTaskHandle xQueueSetSendingTask, xQueueSetReceivingTask;
\r
227 /*-----------------------------------------------------------*/
\r
229 void vStartQueueSetTasks( void )
\r
231 /* Create the tasks. */
\r
232 xTaskCreate( prvQueueSetSendingTask, ( signed char * ) "SetTx", configMINIMAL_STACK_SIZE, NULL, queuesetMEDIUM_PRIORITY, &xQueueSetSendingTask );
\r
233 xTaskCreate( prvQueueSetReceivingTask, ( signed char * ) "SetRx", configMINIMAL_STACK_SIZE, ( void * ) xQueueSetSendingTask, queuesetMEDIUM_PRIORITY, &xQueueSetReceivingTask );
\r
235 /* It is important that the sending task does not attempt to write to a
\r
236 queue before the queue has been created. It is therefore placed into the
\r
237 suspended state before the scheduler has started. It is resumed by the
\r
238 receiving task after the receiving task has created the queues and added the
\r
239 queues to the queue set. */
\r
240 vTaskSuspend( xQueueSetSendingTask );
\r
242 /*-----------------------------------------------------------*/
\r
244 portBASE_TYPE xAreQueueSetTasksStillRunning( void )
\r
246 static unsigned long ulLastCycleCounter, ulLastISRTxValue = 0;
\r
247 static unsigned long ulLastQueueUsedCounter[ queuesetNUM_QUEUES_IN_SET ] = { 0 };
\r
248 portBASE_TYPE xReturn = pdPASS, x;
\r
250 if( ulLastCycleCounter == ulCycleCounter )
\r
252 /* The cycle counter is no longer being incremented. Either one of the
\r
253 tasks is stalled or an error has been detected. */
\r
257 ulLastCycleCounter = ulCycleCounter;
\r
259 /* Ensure that all the queues in the set have been used. This ensures the
\r
260 test is working as intended and guards against the rand() in the Tx task
\r
261 missing some values. */
\r
262 for( x = 0; x < queuesetNUM_QUEUES_IN_SET; x++ )
\r
264 if( ulLastQueueUsedCounter[ x ] == ulQueueUsedCounter[ x ] )
\r
269 ulLastQueueUsedCounter[ x ] = ulQueueUsedCounter[ x ];
\r
272 /* Check the global status flag. */
\r
273 if( xQueueSetTasksStatus != pdPASS )
\r
278 /* Check that the ISR is still sending values to the queues too. */
\r
279 if( ulISRTxValue == ulLastISRTxValue )
\r
285 ulLastISRTxValue = ulISRTxValue;
\r
290 /*-----------------------------------------------------------*/
\r
292 static void prvQueueSetSendingTask( void *pvParameters )
\r
294 unsigned long ulTaskTxValue = 0, ulQueueToWriteTo;
\r
295 xQueueHandle xQueueInUse;
\r
297 /* Remove compiler warning about the unused parameter. */
\r
298 ( void ) pvParameters;
\r
300 /* Seed mini pseudo random number generator. */
\r
301 prvSRand( ( unsigned long ) &ulTaskTxValue );
\r
305 /* Generate the index for the queue to which a value is to be sent. */
\r
306 ulQueueToWriteTo = prvRand() % queuesetNUM_QUEUES_IN_SET;
\r
307 xQueueInUse = xQueues[ ulQueueToWriteTo ];
\r
309 /* Note which index is being written to to ensure all the queues are
\r
311 ( ulQueueUsedCounter[ ulQueueToWriteTo ] )++;
\r
313 /* Send to the queue to unblock the task that is waiting for data to
\r
314 arrive on a queue within the queue set to which this queue belongs. */
\r
315 if( xQueueSendToBack( xQueueInUse, &ulTaskTxValue, portMAX_DELAY ) != pdPASS )
\r
317 /* The send should always pass as an infinite block time was
\r
319 xQueueSetTasksStatus = pdFAIL;
\r
324 /* If the Tx value has reached the range used by the ISR then set it
\r
326 if( ulTaskTxValue == queuesetINITIAL_ISR_TX_VALUE )
\r
331 /* Increase test coverage by occasionally change the priorities of the
\r
332 two tasks relative to each other. */
\r
333 prvChangeRelativePriorities();
\r
336 /*-----------------------------------------------------------*/
\r
338 static void prvChangeRelativePriorities( void )
\r
340 static unsigned portBASE_TYPE ulLoops = 0;
\r
341 static eRelativePriorities ePriorities = eEqualPriority;
\r
343 /* Occasionally change the task priority relative to the priority of
\r
344 the receiving task. */
\r
346 if( ulLoops >= queuesetPRIORITY_CHANGE_LOOPS )
\r
350 switch( ePriorities )
\r
352 case eEqualPriority:
\r
353 /* Both tasks are running with medium priority. Now lower the
\r
354 priority of the receiving task so the Tx task has the higher
\r
355 relative priority. */
\r
356 vTaskPrioritySet( xQueueSetReceivingTask, queuesetLOW_PRIORITY );
\r
357 ePriorities = eTxHigherPriority;
\r
360 case eTxHigherPriority:
\r
361 /* The Tx task is running with a higher priority than the Rx
\r
362 task. Switch the priorities around so the Rx task has the
\r
363 higher relative priority. */
\r
364 vTaskPrioritySet( xQueueSetReceivingTask, queuesetMEDIUM_PRIORITY );
\r
365 vTaskPrioritySet( xQueueSetSendingTask, queuesetLOW_PRIORITY );
\r
366 ePriorities = eTxLowerPriority;
\r
369 case eTxLowerPriority:
\r
370 /* The Tx task is running with a lower priority than the Rx
\r
371 task. Make the priorities equal again. */
\r
372 vTaskPrioritySet( xQueueSetSendingTask, queuesetMEDIUM_PRIORITY );
\r
373 ePriorities = eEqualPriority;
\r
375 /* When both tasks are using a non-idle priority the queue set
\r
376 tasks will starve idle priority tasks of execution time - so
\r
377 relax a bit before the next iteration to minimise the impact. */
\r
378 vTaskDelay( queuesetTX_LOOP_DELAY );
\r
384 /*-----------------------------------------------------------*/
\r
386 static void prvQueueSetReceivingTask( void *pvParameters )
\r
388 unsigned long ulReceived;
\r
389 xQueueHandle xActivatedQueue;
\r
391 /* Remove compiler warnings. */
\r
392 ( void ) pvParameters;
\r
394 /* Create the queues and add them to the queue set before resuming the Tx
\r
400 /* Wait for a message to arrive on one of the queues in the set. */
\r
401 xActivatedQueue = xQueueSelectFromSet( xQueueSet, portMAX_DELAY );
\r
402 configASSERT( xActivatedQueue );
\r
404 if( xActivatedQueue == NULL )
\r
406 /* This should not happen as an infinite delay was used. */
\r
407 xQueueSetTasksStatus = pdFAIL;
\r
411 /* Reading from the queue should pass with a zero block time as
\r
412 this task will only run when something has been posted to a task
\r
413 in the queue set. */
\r
414 if( xQueueReceive( xActivatedQueue, &ulReceived, queuesetDONT_BLOCK ) != pdPASS )
\r
416 xQueueSetTasksStatus = pdFAIL;
\r
419 /* Ensure the value received was the value expected. This function
\r
420 manipulates file scope data and is also called from an ISR, hence
\r
421 the critical section. */
\r
422 taskENTER_CRITICAL();
\r
424 prvCheckReceivedValue( ulReceived );
\r
426 taskEXIT_CRITICAL();
\r
429 if( xQueueSetTasksStatus == pdPASS )
\r
435 /*-----------------------------------------------------------*/
\r
437 void vQueueSetAccessQueueSetFromISR( void )
\r
439 static unsigned long ulCallCount = 0;
\r
441 /* xSetupComplete is set to pdTRUE when the queues have been created and
\r
442 are available for use. */
\r
443 if( xSetupComplete == pdTRUE )
\r
445 /* It is intended that this function is called from the tick hook
\r
446 function, so each call is one tick period apart. */
\r
448 if( ulCallCount > queuesetISR_TX_PERIOD )
\r
452 /* First attempt to read from the queue set. */
\r
453 prvReceiveFromQueueInSetFromISR();
\r
455 /* Then write to the queue set. */
\r
456 prvSendToQueueInSetFromISR();
\r
460 /*-----------------------------------------------------------*/
\r
462 static void prvCheckReceivedValue( unsigned long ulReceived )
\r
464 static unsigned long ulExpectedReceivedFromTask = 0, ulExpectedReceivedFromISR = queuesetINITIAL_ISR_TX_VALUE;
\r
466 /* Values are received in tasks and interrupts. It is likely that the
\r
467 receiving task will sometimes get preempted by the receiving interrupt
\r
468 between reading a value from the queue and calling this function. When
\r
469 that happens, if the receiving interrupt calls this function the values
\r
470 will get passed into this function slightly out of order. For that
\r
471 reason the value passed in is tested against a small range of expected
\r
472 values, rather than a single absolute value. To make the range testing
\r
473 easier values in the range limits are ignored. */
\r
475 /* If the received value is equal to or greater than
\r
476 queuesetINITIAL_ISR_TX_VALUE then it was sent by an ISR. */
\r
477 if( ulReceived >= queuesetINITIAL_ISR_TX_VALUE )
\r
479 /* The value was sent from the ISR. */
\r
480 if( ( ulReceived - queuesetINITIAL_ISR_TX_VALUE ) < queuesetIGNORED_BOUNDARY )
\r
482 /* The value received is at the lower limit of the expected range.
\r
483 Don't test it and expect to receive one higher next time. */
\r
485 else if( ( ULONG_MAX - ulReceived ) <= queuesetIGNORED_BOUNDARY )
\r
487 /* The value received is at the higher limit of the expected range.
\r
488 Don't test it and expect to wrap soon. */
\r
492 /* Check the value against its expected value range. */
\r
493 if( prvCheckReceivedValueWithinExpectedRange( ulReceived, ulExpectedReceivedFromISR ) != pdPASS )
\r
495 xQueueSetTasksStatus = pdFAIL;
\r
499 configASSERT( xQueueSetTasksStatus );
\r
501 /* It is expected to receive an incrementing number. */
\r
502 ulExpectedReceivedFromISR++;
\r
503 if( ulExpectedReceivedFromISR == 0 )
\r
505 ulExpectedReceivedFromISR = queuesetINITIAL_ISR_TX_VALUE;
\r
510 /* The value was sent from the Tx task. */
\r
511 if( ulReceived < queuesetIGNORED_BOUNDARY )
\r
513 /* The value received is at the lower limit of the expected range.
\r
514 Don't test it, and expect to receive one higher next time. */
\r
516 else if( ( ( queuesetINITIAL_ISR_TX_VALUE - 1 ) - ulReceived ) <= queuesetIGNORED_BOUNDARY )
\r
518 /* The value received is at the higher limit of the expected range.
\r
519 Don't test it and expect to wrap soon. */
\r
523 /* Check the value against its expected value range. */
\r
524 if( prvCheckReceivedValueWithinExpectedRange( ulReceived, ulExpectedReceivedFromTask ) != pdPASS )
\r
526 xQueueSetTasksStatus = pdFAIL;
\r
530 configASSERT( xQueueSetTasksStatus );
\r
532 /* It is expected to receive an incrementing number. */
\r
533 ulExpectedReceivedFromTask++;
\r
534 if( ulExpectedReceivedFromTask >= queuesetINITIAL_ISR_TX_VALUE )
\r
536 ulExpectedReceivedFromTask = 0;
\r
540 /*-----------------------------------------------------------*/
\r
542 static portBASE_TYPE prvCheckReceivedValueWithinExpectedRange( unsigned long ulReceived, unsigned long ulExpectedReceived )
\r
544 portBASE_TYPE xReturn = pdPASS;
\r
546 if( ulReceived > ulExpectedReceived )
\r
548 configASSERT( ( ulReceived - ulExpectedReceived ) <= queuesetALLOWABLE_RX_DEVIATION );
\r
549 if( ( ulReceived - ulExpectedReceived ) > queuesetALLOWABLE_RX_DEVIATION )
\r
556 configASSERT( ( ulExpectedReceived - ulReceived ) <= queuesetALLOWABLE_RX_DEVIATION );
\r
557 if( ( ulExpectedReceived - ulReceived ) > queuesetALLOWABLE_RX_DEVIATION )
\r
565 /*-----------------------------------------------------------*/
\r
567 static void prvReceiveFromQueueInSetFromISR( void )
\r
569 xQueueSetMemberHandle xActivatedQueue;
\r
570 unsigned long ulReceived;
\r
572 /* See if any of the queues in the set contain data. */
\r
573 xActivatedQueue = xQueueSelectFromSetFromISR( xQueueSet );
\r
575 if( xActivatedQueue != NULL )
\r
577 /* Reading from the queue for test purposes only. */
\r
578 if( xQueueReceiveFromISR( xActivatedQueue, &ulReceived, NULL ) != pdPASS )
\r
580 /* Data should have been available as the handle was returned from
\r
581 xQueueSelectFromSetFromISR(). */
\r
582 xQueueSetTasksStatus = pdFAIL;
\r
585 /* Ensure the value received was the value expected. */
\r
586 prvCheckReceivedValue( ulReceived );
\r
589 /*-----------------------------------------------------------*/
\r
591 static void prvSendToQueueInSetFromISR( void )
\r
593 static portBASE_TYPE xQueueToWriteTo = 0;
\r
595 if( xQueueSendFromISR( xQueues[ xQueueToWriteTo ], ( void * ) &ulISRTxValue, NULL ) == pdPASS )
\r
599 /* If the Tx value has wrapped then set it back to its
\r
601 if( ulISRTxValue == 0UL )
\r
603 ulISRTxValue = queuesetINITIAL_ISR_TX_VALUE;
\r
606 /* Use a different queue next time. */
\r
608 if( xQueueToWriteTo >= queuesetNUM_QUEUES_IN_SET )
\r
610 xQueueToWriteTo = 0;
\r
614 /*-----------------------------------------------------------*/
\r
616 static void prvSetupTest( void )
\r
619 unsigned long ulValueToSend = 0;
\r
621 /* Ensure the queues are created and the queue set configured before the
\r
622 sending task is unsuspended.
\r
624 First Create the queue set such that it will be able to hold a message for
\r
625 every space in every queue in the set. */
\r
626 xQueueSet = xQueueCreateSet( queuesetNUM_QUEUES_IN_SET * queuesetQUEUE_LENGTH );
\r
628 for( x = 0; x < queuesetNUM_QUEUES_IN_SET; x++ )
\r
630 /* Create the queue and add it to the set. The queue is just holding
\r
631 unsigned long value. */
\r
632 xQueues[ x ] = xQueueCreate( queuesetQUEUE_LENGTH, sizeof( unsigned long ) );
\r
633 configASSERT( xQueues[ x ] );
\r
634 if( xQueueAddToSet( xQueues[ x ], xQueueSet ) != pdPASS )
\r
636 xQueueSetTasksStatus = pdFAIL;
\r
640 /* The queue has now been added to the queue set and cannot be added to
\r
642 if( xQueueAddToSet( xQueues[ x ], xQueueSet ) != pdFAIL )
\r
644 xQueueSetTasksStatus = pdFAIL;
\r
649 /* Attempt to remove a queue from a queue set it does not belong
\r
650 to (NULL being passed as the queue set in this case). */
\r
651 if( xQueueRemoveFromSet( xQueues[ 0 ], NULL ) != pdFAIL )
\r
653 /* It is not possible to successfully remove a queue from a queue
\r
654 set it does not belong to. */
\r
655 xQueueSetTasksStatus = pdFAIL;
\r
658 /* Attempt to remove a queue from the queue set it does belong to. */
\r
659 if( xQueueRemoveFromSet( xQueues[ 0 ], xQueueSet ) != pdPASS )
\r
661 /* It should be possible to remove the queue from the queue set it
\r
663 xQueueSetTasksStatus = pdFAIL;
\r
666 /* Add an item to the queue before attempting to add it back into the
\r
668 xQueueSend( xQueues[ 0 ], ( void * ) &ulValueToSend, 0 );
\r
669 if( xQueueAddToSet( xQueues[ 0 ], xQueueSet ) != pdFAIL )
\r
671 /* Should not be able to add a non-empty queue to a set. */
\r
672 xQueueSetTasksStatus = pdFAIL;
\r
675 /* Remove the item from the queue before adding the queue back into the
\r
676 set so the dynamic tests can begin. */
\r
677 xQueueReceive( xQueues[ 0 ], &ulValueToSend, 0 );
\r
678 if( xQueueAddToSet( xQueues[ 0 ], xQueueSet ) != pdPASS )
\r
680 /* If the queue was successfully removed from the queue set then it
\r
681 should be possible to add it back in again. */
\r
682 xQueueSetTasksStatus = pdFAIL;
\r
685 /* The task that sends to the queues is not running yet, so attempting to
\r
686 read from the queue set should fail. */
\r
687 if( xQueueSelectFromSet( xQueueSet, queuesetSHORT_DELAY ) != NULL )
\r
689 xQueueSetTasksStatus = pdFAIL;
\r
692 /* Resume the task that writes to the queues. */
\r
693 vTaskResume( xQueueSetSendingTask );
\r
695 /* Let the ISR access the queues also. */
\r
696 xSetupComplete = pdTRUE;
\r
698 /*-----------------------------------------------------------*/
\r
700 static unsigned long prvRand( void )
\r
702 ulNextRand = ( ulNextRand * 1103515245UL ) + 12345UL;
\r
703 return ( ulNextRand / 65536UL ) % 32768UL;
\r
705 /*-----------------------------------------------------------*/
\r
707 static void prvSRand( unsigned long ulSeed )
\r
709 ulNextRand = ulSeed;
\r