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
79 /* Standard includes. */
\r
83 /* Kernel includes. */
\r
84 #include "FreeRTOS.h"
\r
88 /* Demo includes. */
\r
89 #include "QueueSet.h"
\r
91 /* The number of queues that are created and added to the queue set. */
\r
92 #define queuesetNUM_QUEUES_IN_SET 3
\r
94 /* The length of each created queue. */
\r
95 #define queuesetQUEUE_LENGTH 3
\r
97 /* Block times used in this demo. A block time or 0 means "don't block". */
\r
98 #define queuesetSHORT_DELAY 200
\r
99 #define queuesetDONT_BLOCK 0
\r
101 /* Messages are sent in incrementing order from both a task and an interrupt.
\r
102 The task sends values in the range 0 to 0xfffe, and the interrupt sends values
\r
103 in the range of 0xffff to ULONG_MAX. */
\r
104 #define queuesetINITIAL_ISR_TX_VALUE 0xffffUL
\r
106 /* The priorities used in this demo. */
\r
107 #define queuesetLOW_PRIORITY ( tskIDLE_PRIORITY )
\r
108 #define queuesetMEDIUM_PRIORITY ( queuesetLOW_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( void );
\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 tasks. */
\r
231 xTaskCreate( prvQueueSetSendingTask, ( signed char * ) "SetTx", configMINIMAL_STACK_SIZE, NULL, queuesetMEDIUM_PRIORITY, &xQueueSetSendingTask );
\r
232 xTaskCreate( prvQueueSetReceivingTask, ( signed char * ) "SetRx", configMINIMAL_STACK_SIZE, ( void * ) xQueueSetSendingTask, queuesetMEDIUM_PRIORITY, &xQueueSetReceivingTask );
\r
234 /* It is important that the sending task does not attempt to write to a
\r
235 queue before the queue has been created. It is therefore placed into the
\r
236 suspended state before the scheduler has started. It is resumed by the
\r
237 receiving task after the receiving task has created the queues and added the
\r
238 queues to the queue set. */
\r
239 vTaskSuspend( xQueueSetSendingTask );
\r
241 /*-----------------------------------------------------------*/
\r
243 portBASE_TYPE xAreQueueSetTasksStillRunning( void )
\r
245 static unsigned long ulLastCycleCounter, ulLastISRTxValue = 0;
\r
246 static unsigned long ulLastQueueUsedCounter[ queuesetNUM_QUEUES_IN_SET ] = { 0 };
\r
247 portBASE_TYPE xReturn = pdPASS, x;
\r
249 if( ulLastCycleCounter == ulCycleCounter )
\r
251 /* The cycle counter is no longer being incremented. Either one of the
\r
252 tasks is stalled or an error has been detected. */
\r
256 ulLastCycleCounter = ulCycleCounter;
\r
258 /* Ensure that all the queues in the set have been used. This ensures the
\r
259 test is working as intended and guards against the rand() in the Tx task
\r
260 missing some values. */
\r
261 for( x = 0; x < queuesetNUM_QUEUES_IN_SET; x++ )
\r
263 if( ulLastQueueUsedCounter[ x ] == ulQueueUsedCounter[ x ] )
\r
268 ulLastQueueUsedCounter[ x ] = ulQueueUsedCounter[ x ];
\r
271 /* Check the global status flag. */
\r
272 if( xQueueSetTasksStatus != pdPASS )
\r
277 /* Check that the ISR is still sending values to the queues too. */
\r
278 if( ulISRTxValue == ulLastISRTxValue )
\r
284 ulLastISRTxValue = ulISRTxValue;
\r
289 /*-----------------------------------------------------------*/
\r
291 static void prvQueueSetSendingTask( void *pvParameters )
\r
293 unsigned long ulTaskTxValue = 0, ulQueueToWriteTo;
\r
294 xQueueHandle xQueueInUse;
\r
296 /* Remove compiler warning about the unused parameter. */
\r
297 ( void ) pvParameters;
\r
299 /* Seed mini pseudo random number generator. */
\r
300 prvSRand( ( unsigned long ) &ulTaskTxValue );
\r
304 /* Generate the index for the queue to which a value is to be sent. */
\r
305 ulQueueToWriteTo = prvRand() % queuesetNUM_QUEUES_IN_SET;
\r
306 xQueueInUse = xQueues[ ulQueueToWriteTo ];
\r
308 /* Note which index is being written to to ensure all the queues are
\r
310 ( ulQueueUsedCounter[ ulQueueToWriteTo ] )++;
\r
312 /* Send to the queue to unblock the task that is waiting for data to
\r
313 arrive on a queue within the queue set to which this queue belongs. */
\r
314 if( xQueueSendToBack( xQueueInUse, &ulTaskTxValue, portMAX_DELAY ) != pdPASS )
\r
316 /* The send should always pass as an infinite block time was
\r
318 xQueueSetTasksStatus = pdFAIL;
\r
323 /* If the Tx value has reached the range used by the ISR then set it
\r
325 if( ulTaskTxValue == queuesetINITIAL_ISR_TX_VALUE )
\r
330 /* Increase test coverage by occasionally change the priorities of the
\r
331 two tasks relative to each other. */
\r
332 prvChangeRelativePriorities();
\r
335 /*-----------------------------------------------------------*/
\r
337 static void prvChangeRelativePriorities( void )
\r
339 static unsigned portBASE_TYPE ulLoops = 0;
\r
340 static eRelativePriorities ePriorities = eEqualPriority;
\r
342 /* Occasionally change the task priority relative to the priority of
\r
343 the receiving task. */
\r
345 if( ulLoops >= queuesetPRIORITY_CHANGE_LOOPS )
\r
349 switch( ePriorities )
\r
351 case eEqualPriority:
\r
352 /* Both tasks are running with medium priority. Now lower the
\r
353 priority of the receiving task so the Tx task has the higher
\r
354 relative priority. */
\r
355 vTaskPrioritySet( xQueueSetReceivingTask, queuesetLOW_PRIORITY );
\r
356 ePriorities = eTxHigherPriority;
\r
359 case eTxHigherPriority:
\r
360 /* The Tx task is running with a higher priority than the Rx
\r
361 task. Switch the priorities around so the Rx task has the
\r
362 higher relative priority. */
\r
363 vTaskPrioritySet( xQueueSetReceivingTask, queuesetMEDIUM_PRIORITY );
\r
364 vTaskPrioritySet( xQueueSetSendingTask, queuesetLOW_PRIORITY );
\r
365 ePriorities = eTxLowerPriority;
\r
368 case eTxLowerPriority:
\r
369 /* The Tx task is running with a lower priority than the Rx
\r
370 task. Make the priorities equal again. */
\r
371 vTaskPrioritySet( xQueueSetSendingTask, queuesetMEDIUM_PRIORITY );
\r
372 ePriorities = eEqualPriority;
\r
374 /* When both tasks are using a non-idle priority the queue set
\r
375 tasks will starve idle priority tasks of execution time - so
\r
376 relax a bit before the next iteration to minimise the impact. */
\r
377 vTaskDelay( queuesetTX_LOOP_DELAY );
\r
383 /*-----------------------------------------------------------*/
\r
385 static void prvQueueSetReceivingTask( void *pvParameters )
\r
387 unsigned long ulReceived;
\r
388 xQueueHandle xActivatedQueue;
\r
390 /* Create the queues and add them to the queue set before resuming the Tx
\r
396 /* Wait for a message to arrive on one of the queues in the set. */
\r
397 xActivatedQueue = xQueueSelectFromSet( xQueueSet, portMAX_DELAY );
\r
398 configASSERT( xActivatedQueue );
\r
400 if( xActivatedQueue == NULL )
\r
402 /* This should not happen as an infinite delay was used. */
\r
403 xQueueSetTasksStatus = pdFAIL;
\r
407 /* Reading from the queue should pass with a zero block time as
\r
408 this task will only run when something has been posted to a task
\r
409 in the queue set. */
\r
410 if( xQueueReceive( xActivatedQueue, &ulReceived, queuesetDONT_BLOCK ) != pdPASS )
\r
412 xQueueSetTasksStatus = pdFAIL;
\r
415 /* Ensure the value received was the value expected. This function
\r
416 manipulates file scope data and is also called from an ISR, hence
\r
417 the critical section. */
\r
418 taskENTER_CRITICAL();
\r
420 prvCheckReceivedValue( ulReceived );
\r
422 taskEXIT_CRITICAL();
\r
425 if( xQueueSetTasksStatus == pdPASS )
\r
431 /*-----------------------------------------------------------*/
\r
433 void vQueueSetAccessQueueSetFromISR( void )
\r
435 static unsigned long ulCallCount = 0;
\r
437 /* xSetupComplete is set to pdTRUE when the queues have been created and
\r
438 are available for use. */
\r
439 if( xSetupComplete == pdTRUE )
\r
441 /* It is intended that this function is called from the tick hook
\r
442 function, so each call is one tick period apart. */
\r
444 if( ulCallCount > queuesetISR_TX_PERIOD )
\r
448 /* First attempt to read from the queue set. */
\r
449 prvReceiveFromQueueInSetFromISR();
\r
451 /* Then write to the queue set. */
\r
452 prvSendToQueueInSetFromISR();
\r
456 /*-----------------------------------------------------------*/
\r
458 static void prvCheckReceivedValue( unsigned long ulReceived )
\r
460 static unsigned long ulExpectedReceivedFromTask = 0, ulExpectedReceivedFromISR = queuesetINITIAL_ISR_TX_VALUE;
\r
462 /* Values are received in tasks and interrupts. It is likely that the
\r
463 receiving task will sometimes get preempted by the receiving interrupt
\r
464 between reading a value from the queue and calling this function. When
\r
465 that happens, if the receiving interrupt calls this function the values
\r
466 will get passed into this function slightly out of order. For that
\r
467 reason the value passed in is tested against a small range of expected
\r
468 values, rather than a single absolute value. To make the range testing
\r
469 easier values in the range limits are ignored. */
\r
471 /* If the received value is equal to or greater than
\r
472 queuesetINITIAL_ISR_TX_VALUE then it was sent by an ISR. */
\r
473 if( ulReceived >= queuesetINITIAL_ISR_TX_VALUE )
\r
475 /* The value was sent from the ISR. */
\r
476 if( ( ulReceived - queuesetINITIAL_ISR_TX_VALUE ) < queuesetIGNORED_BOUNDARY )
\r
478 /* The value received is at the lower limit of the expected range.
\r
479 Don't test it and expect to receive one higher next time. */
\r
481 else if( ( ULONG_MAX - ulReceived ) <= queuesetIGNORED_BOUNDARY )
\r
483 /* The value received is at the higher limit of the expected range.
\r
484 Don't test it and expect to wrap soon. */
\r
488 /* Check the value against its expected value range. */
\r
489 if( prvCheckReceivedValueWithinExpectedRange( ulReceived, ulExpectedReceivedFromISR ) != pdPASS )
\r
491 xQueueSetTasksStatus = pdFAIL;
\r
495 configASSERT( xQueueSetTasksStatus );
\r
497 /* It is expected to receive an incrementing number. */
\r
498 ulExpectedReceivedFromISR++;
\r
499 if( ulExpectedReceivedFromISR == 0 )
\r
501 ulExpectedReceivedFromISR = queuesetINITIAL_ISR_TX_VALUE;
\r
506 /* The value was sent from the Tx task. */
\r
507 if( ulReceived < queuesetIGNORED_BOUNDARY )
\r
509 /* The value received is at the lower limit of the expected range.
\r
510 Don't test it, and expect to receive one higher next time. */
\r
512 else if( ( ( queuesetINITIAL_ISR_TX_VALUE - 1 ) - ulReceived ) <= queuesetIGNORED_BOUNDARY )
\r
514 /* The value received is at the higher limit of the expected range.
\r
515 Don't test it and expect to wrap soon. */
\r
519 /* Check the value against its expected value range. */
\r
520 if( prvCheckReceivedValueWithinExpectedRange( ulReceived, ulExpectedReceivedFromTask ) != pdPASS )
\r
522 xQueueSetTasksStatus = pdFAIL;
\r
526 configASSERT( xQueueSetTasksStatus );
\r
528 /* It is expected to receive an incrementing number. */
\r
529 ulExpectedReceivedFromTask++;
\r
530 if( ulExpectedReceivedFromTask >= queuesetINITIAL_ISR_TX_VALUE )
\r
532 ulExpectedReceivedFromTask = 0;
\r
536 /*-----------------------------------------------------------*/
\r
538 static portBASE_TYPE prvCheckReceivedValueWithinExpectedRange( unsigned long ulReceived, unsigned long ulExpectedReceived )
\r
540 portBASE_TYPE xReturn = pdPASS;
\r
542 if( ulReceived > ulExpectedReceived )
\r
544 configASSERT( ( ulReceived - ulExpectedReceived ) <= queuesetALLOWABLE_RX_DEVIATION );
\r
545 if( ( ulReceived - ulExpectedReceived ) > queuesetALLOWABLE_RX_DEVIATION )
\r
552 configASSERT( ( ulExpectedReceived - ulReceived ) <= queuesetALLOWABLE_RX_DEVIATION );
\r
553 if( ( ulExpectedReceived - ulReceived ) > queuesetALLOWABLE_RX_DEVIATION )
\r
561 /*-----------------------------------------------------------*/
\r
563 static void prvReceiveFromQueueInSetFromISR( void )
\r
565 xQueueSetMemberHandle xActivatedQueue;
\r
566 unsigned long ulReceived;
\r
568 /* See if any of the queues in the set contain data. */
\r
569 xActivatedQueue = xQueueSelectFromSetFromISR( xQueueSet );
\r
571 if( xActivatedQueue != NULL )
\r
573 /* Reading from the queue for test purposes only. */
\r
574 if( xQueueReceiveFromISR( xActivatedQueue, &ulReceived, NULL ) != pdPASS )
\r
576 /* Data should have been available as the handle was returned from
\r
577 xQueueSelectFromSetFromISR(). */
\r
578 xQueueSetTasksStatus = pdFAIL;
\r
581 /* Ensure the value received was the value expected. */
\r
582 prvCheckReceivedValue( ulReceived );
\r
585 /*-----------------------------------------------------------*/
\r
587 static void prvSendToQueueInSetFromISR( void )
\r
589 static portBASE_TYPE xQueueToWriteTo = 0;
\r
591 if( xQueueSendFromISR( xQueues[ xQueueToWriteTo ], ( void * ) &ulISRTxValue, NULL ) == pdPASS )
\r
595 /* If the Tx value has wrapped then set it back to its
\r
597 if( ulISRTxValue == 0UL )
\r
599 ulISRTxValue = queuesetINITIAL_ISR_TX_VALUE;
\r
602 /* Use a different queue next time. */
\r
604 if( xQueueToWriteTo >= queuesetNUM_QUEUES_IN_SET )
\r
606 xQueueToWriteTo = 0;
\r
610 /*-----------------------------------------------------------*/
\r
612 static void prvSetupTest( void )
\r
615 unsigned long ulValueToSend = 0;
\r
617 /* Ensure the queues are created and the queue set configured before the
\r
618 sending task is unsuspended.
\r
620 First Create the queue set such that it will be able to hold a message for
\r
621 every space in every queue in the set. */
\r
622 xQueueSet = xQueueCreateSet( queuesetNUM_QUEUES_IN_SET * queuesetQUEUE_LENGTH );
\r
624 for( x = 0; x < queuesetNUM_QUEUES_IN_SET; x++ )
\r
626 /* Create the queue and add it to the set. The queue is just holding
\r
627 unsigned long value. */
\r
628 xQueues[ x ] = xQueueCreate( queuesetQUEUE_LENGTH, sizeof( unsigned long ) );
\r
629 configASSERT( xQueues[ x ] );
\r
630 if( xQueueAddToSet( xQueues[ x ], xQueueSet ) != pdPASS )
\r
632 xQueueSetTasksStatus = pdFAIL;
\r
636 /* The queue has now been added to the queue set and cannot be added to
\r
638 if( xQueueAddToSet( xQueues[ x ], xQueueSet ) != pdFAIL )
\r
640 xQueueSetTasksStatus = pdFAIL;
\r
645 /* Attempt to remove a queue from a queue set it does not belong
\r
646 to (NULL being passed as the queue set in this case). */
\r
647 if( xQueueRemoveFromSet( xQueues[ 0 ], NULL ) != pdFAIL )
\r
649 /* It is not possible to successfully remove a queue from a queue
\r
650 set it does not belong to. */
\r
651 xQueueSetTasksStatus = pdFAIL;
\r
654 /* Attempt to remove a queue from the queue set it does belong to. */
\r
655 if( xQueueRemoveFromSet( xQueues[ 0 ], xQueueSet ) != pdPASS )
\r
657 /* It should be possible to remove the queue from the queue set it
\r
659 xQueueSetTasksStatus = pdFAIL;
\r
662 /* Add an item to the queue before attempting to add it back into the
\r
664 xQueueSend( xQueues[ 0 ], ( void * ) &ulValueToSend, 0 );
\r
665 if( xQueueAddToSet( xQueues[ 0 ], xQueueSet ) != pdFAIL )
\r
667 /* Should not be able to add a non-empty queue to a set. */
\r
668 xQueueSetTasksStatus = pdFAIL;
\r
671 /* Remove the item from the queue before adding the queue back into the
\r
672 set so the dynamic tests can begin. */
\r
673 xQueueReceive( xQueues[ 0 ], &ulValueToSend, 0 );
\r
674 if( xQueueAddToSet( xQueues[ 0 ], xQueueSet ) != pdPASS )
\r
676 /* If the queue was successfully removed from the queue set then it
\r
677 should be possible to add it back in again. */
\r
678 xQueueSetTasksStatus = pdFAIL;
\r
681 /* The task that sends to the queues is not running yet, so attempting to
\r
682 read from the queue set should fail. */
\r
683 if( xQueueSelectFromSet( xQueueSet, queuesetSHORT_DELAY ) != NULL )
\r
685 xQueueSetTasksStatus = pdFAIL;
\r
688 /* Resume the task that writes to the queues. */
\r
689 vTaskResume( xQueueSetSendingTask );
\r
691 /* Let the ISR access the queues also. */
\r
692 xSetupComplete = pdTRUE;
\r
694 /*-----------------------------------------------------------*/
\r
696 static unsigned long prvRand( void )
\r
698 ulNextRand = ( ulNextRand * 1103515245UL ) + 12345UL;
\r
699 return ( ulNextRand / 65536UL ) % 32768UL;
\r
701 /*-----------------------------------------------------------*/
\r
703 static void prvSRand( unsigned long ulSeed )
\r
705 ulNextRand = ulSeed;
\r