+static void prvDemoQueueSpaceFunctions( void *pvParameters )\r
+{\r
+xQueueHandle xQueue = NULL;\r
+const unsigned portBASE_TYPE uxQueueLength = 10;\r
+unsigned portBASE_TYPE uxReturn, x;\r
+\r
+ /* Remove compiler warnings. */\r
+ ( void ) pvParameters;\r
+\r
+ /* Create the queue that will be used. Nothing is actually going to be\r
+ sent or received so the queue item size is set to 0. */\r
+ xQueue = xQueueCreate( uxQueueLength, 0 );\r
+ configASSERT( xQueue );\r
+\r
+ for( ;; )\r
+ {\r
+ for( x = 0; x < uxQueueLength; x++ )\r
+ {\r
+ /* Ask how many messages are available... */\r
+ uxReturn = uxQueueMessagesWaiting( xQueue );\r
+ \r
+ /* Check the number of messages being reported as being available\r
+ is as expected, and force an assert if not. */\r
+ if( uxReturn != x )\r
+ {\r
+ /* xQueue cannot be NULL so this is deliberately causing an\r
+ assert to be triggered as there is an error. */\r
+ configASSERT( xQueue == NULL );\r
+ }\r
+\r
+ /* Ask how many spaces remain in the queue... */\r
+ uxReturn = uxQueueSpacesAvailable( xQueue );\r
+ \r
+ /* Check the number of spaces being reported as being available\r
+ is as expected, and force an assert if not. */\r
+ if( uxReturn != ( uxQueueLength - x ) )\r
+ {\r
+ /* xQueue cannot be NULL so this is deliberately causing an\r
+ assert to be triggered as there is an error. */\r
+ configASSERT( xQueue == NULL );\r
+ }\r
+\r
+ /* Fill one more space in the queue. */\r
+ xQueueSendToBack( xQueue, NULL, 0 );\r
+ }\r
+\r
+ /* Perform the same check while the queue is full. */\r
+ uxReturn = uxQueueMessagesWaiting( xQueue );\r
+ if( uxReturn != uxQueueLength )\r
+ {\r
+ configASSERT( xQueue == NULL );\r
+ }\r
+\r
+ uxReturn = uxQueueSpacesAvailable( xQueue );\r
+ \r
+ if( uxReturn != 0 )\r
+ {\r
+ configASSERT( xQueue == NULL );\r
+ }\r
+\r
+ /* The queue is full, start again. */\r
+ xQueueReset( xQueue );\r
+ }\r
+}\r
+\r