]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Source/include/queue.h
Next revision of queue set implementation.
[freertos] / FreeRTOS / Source / include / queue.h
index e48cf07a6d8083f040714b7cff7f15e59ee43262..b9452662cf5883a2bdab926513436653ec4414f2 100644 (file)
@@ -1,6 +1,8 @@
 /*\r
-    FreeRTOS V7.2.0 - Copyright (C) 2012 Real Time Engineers Ltd.\r
+    FreeRTOS V7.3.0 - Copyright (C) 2012 Real Time Engineers Ltd.\r
 \r
+    FEATURES AND PORTS ARE ADDED TO FREERTOS ALL THE TIME.  PLEASE VISIT\r
+    http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
 \r
     ***************************************************************************\r
      *                                                                       *\r
     FreeRTOS WEB site.\r
 \r
     1 tab == 4 spaces!\r
-    \r
+\r
     ***************************************************************************\r
      *                                                                       *\r
      *    Having a problem?  Start by reading the FAQ "My application does   *\r
-     *    not run, what could be wrong?                                      *\r
+     *    not run, what could be wrong?"                                     *\r
      *                                                                       *\r
      *    http://www.FreeRTOS.org/FAQHelp.html                               *\r
      *                                                                       *\r
     ***************************************************************************\r
 \r
-    \r
-    http://www.FreeRTOS.org - Documentation, training, latest information, \r
-    license and contact details.\r
-    \r
+\r
+    http://www.FreeRTOS.org - Documentation, training, latest versions, license\r
+    and contact details.\r
+\r
     http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
     including FreeRTOS+Trace - an indispensable productivity tool.\r
 \r
-    Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell \r
-    the code with commercial support, indemnification, and middleware, under \r
+    Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell\r
+    the code with commercial support, indemnification, and middleware, under\r
     the OpenRTOS brand: http://www.OpenRTOS.com.  High Integrity Systems also\r
-    provide a safety engineered and independently SIL3 certified version under \r
+    provide a safety engineered and independently SIL3 certified version under\r
     the SafeRTOS brand: http://www.SafeRTOS.com.\r
 */\r
 \r
@@ -80,12 +82,18 @@ extern "C" {
 #include "mpu_wrappers.h"\r
 \r
 /**\r
- * Type by which queues are referenced.  For example, a call to xQueueCreate\r
- * returns (via a pointer parameter) an xQueueHandle variable that can then\r
- * be used as a parameter to xQueueSend(), xQueueReceive(), etc.\r
+ * Type by which queues are referenced.  For example, a call to xQueueCreate()\r
+ * returns an xQueueHandle variable that can then be used as a parameter to\r
+ * xQueueSend(), xQueueReceive(), etc.\r
  */\r
 typedef void * xQueueHandle;\r
 \r
+/**\r
+ * Type by which queue sets are referenced.  For example, a call to\r
+ * xQueueSetCreate() returns an xQueueSet variable that can then be used as a\r
+ * parameter to xQueueReadMultiple(), xQueueAddToQueueSet(), etc.\r
+ */\r
+typedef void * xQueueSetHandle;\r
 \r
 /* For internal use only. */\r
 #define        queueSEND_TO_BACK       ( 0 )\r
@@ -1234,8 +1242,8 @@ signed portBASE_TYPE xQueueCRSend( xQueueHandle pxQueue, const void *pvItemToQue
 signed portBASE_TYPE xQueueCRReceive( xQueueHandle pxQueue, void *pvBuffer, portTickType xTicksToWait );\r
 \r
 /*\r
- * For internal use only.  Use xSemaphoreCreateMutex(), \r
- * xSemaphoreCreateCounting() or xSemaphoreGetMutexHolder() instead of calling \r
+ * For internal use only.  Use xSemaphoreCreateMutex(),\r
+ * xSemaphoreCreateCounting() or xSemaphoreGetMutexHolder() instead of calling\r
  * these functions directly.\r
  */\r
 xQueueHandle xQueueCreateMutex( unsigned char ucQueueType );\r
@@ -1282,11 +1290,128 @@ portBASE_TYPE xQueueGiveMutexRecursive( xQueueHandle pxMutex );
 #endif\r
 \r
 /*\r
- * Generic version of the queue creation function, which is in turn called by \r
+ * Generic version of the queue creation function, which is in turn called by\r
  * any queue, semaphore or mutex creation function or macro.\r
  */\r
 xQueueHandle xQueueGenericCreate( unsigned portBASE_TYPE uxQueueLength, unsigned portBASE_TYPE uxItemSize, unsigned char ucQueueType );\r
 \r
+/*\r
+ * Queue sets provide a mechanism to allow a task to block (pend) on a read\r
+ * operation from multiple queues or semaphores simultaneously.\r
+ *\r
+ * See FreeRTOS/Source/Demo/Common/Minimal/QueueSet.c for an example using this\r
+ * function.\r
+ *\r
+ * A queue set must be explicitly created using a call to xQueueSetCreate()\r
+ * before it can be used.  Once created, standard FreeRTOS queues and semaphores\r
+ * can be added to the set using calls to xQueueAddToQueueSet().\r
+ * xQueueReadMultiple() is then used to determine which, if any, of the queues\r
+ * or semaphores contained in the set is in a state where a queue read or\r
+ * semaphore take operation would be successful.\r
+ *\r
+ * Note 1:  See the documentation on http://wwwFreeRTOS.org for reasons why\r
+ * queue sets are very rarely needed in practice as there are simpler\r
+ * alternatives.  Queue sets are provided to allow FreeRTOS to be integrated\r
+ * with legacy third party driver code.\r
+ *\r
+ * Note 2:  Blocking on a queue set that contains a mutex will not cause the\r
+ * mutex holder to inherit the priority of the blocked task.\r
+ *\r
+ * Note 3:  An additional 4 bytes of RAM is required for each space in a every\r
+ * queue added to a queue set.  Therefore counting semaphores with large maximum\r
+ * counts should not be added to queue sets.\r
+ *\r
+ * @param uxEventQueueLength Queue sets themselves queue events that occur on\r
+ * the queues and semaphores contained in the set.  uxEventQueueLength specifies\r
+ * the maximum number of events that can be queued at once.  To be absolutely\r
+ * certain that events are not lost uxEventQueueLength should be set to the\r
+ * total sum of the length of the queues added to the set, where binary\r
+ * semaphores and mutexes have a length of 1, and counting semaphores have a\r
+ * length set by their maximum count value.  Examples:\r
+ *  + If a queue set is to hold a queue of length 5, another queue of length 12,\r
+ *    and a binary semaphore, then uxEventQueueLength should be set to\r
+ *    (5 + 12 + 1), or 18.\r
+ *  + If a queue set is to hold three binary semaphores then uxEventQueueLength\r
+ *    should be set to (1 + 1 + 1 ), or 3.\r
+ *  + If a queue set is to hold a counting semaphore that has a maximum count of\r
+ *    5, and a counting semaphore that has a maximum count of 3, then\r
+ *    uxEventQueueLength should be set to (5 + 3), or 8.\r
+ *\r
+ * @return If the queue set is created successfully then a handle to the created\r
+ * queue set is returned.  Otherwise NULL is returned.\r
+ */\r
+xQueueSetHandle xQueueSetCreate( unsigned portBASE_TYPE uxEventQueueLength );\r
+\r
+/*\r
+ * Adds a queue or semaphore to a queue set that was previously created by a\r
+ * call to xQueueSetCreate().\r
+ *\r
+ * See FreeRTOS/Source/Demo/Common/Minimal/QueueSet.c for an example using this\r
+ * function.\r
+ *\r
+ * @param xQueue The handle of the queue or semaphore being added to the\r
+ * queue set.  Variables of type xSemaphoreHandle can be safely added to a\r
+ * queue set but may require casting to an xQueueHandle type to avoid compiler\r
+ * warnings.\r
+ *\r
+ * @param xQueueSet The handle of the queue set to which the queue or semaphore\r
+ * is being added.\r
+ *\r
+ * @return If the queue or semaphore was successfully added to the queue set \r
+ * then pdPASS is returned.  If the queue could not be successfully added to the \r
+ * queue set because it is already a member of a different queue set then pdFAIL \r
+ * is returned.\r
+ */\r
+portBASE_TYPE xQueueAddToQueueSet( xQueueHandle xQueue, xQueueSetHandle xQueueSet );\r
+\r
+/*\r
+ * Removes a queue or semaphore from a queue set.\r
+ *\r
+ * See FreeRTOS/Source/Demo/Common/Minimal/QueueSet.c for an example using this\r
+ * function.\r
+ *\r
+ * @param xQueue The handle of the queue or semaphore being removed from the\r
+ * queue set.  Variables of type xSemaphoreHandle can be safely used but may \r
+ * require casting to an xQueueHandle type to avoid compiler warnings.\r
+ *\r
+ * @param xQueueSet The handle of the queue set in which the queue or semaphore\r
+ * is included.\r
+ *\r
+ * @return If the queue or semaphore was successfully removed from the queue set \r
+ * then pdPASS is returned.  If the queue was not in the queue set then pdFAIL\r
+ * is returned.\r
+ */\r
+portBASE_TYPE xQueueRemoveFromQueueSet( xQueueSetHandle xQueueSet, xQueueHandle xQueue );\r
+\r
+/*\r
+ * xQueueReadMultiple() allows a task to block (pend) on a read operation on\r
+ * all the queues and semaphores in a queue set simultaneously.\r
+ *\r
+ * See FreeRTOS/Source/Demo/Common/Minimal/QueueSet.c for an example using this\r
+ * function.\r
+ *\r
+ * Note 1:  See the documentation on http://wwwFreeRTOS.org for reasons why\r
+ * queue sets are very rarely needed in practice as there are simpler\r
+ * alternatives.  Queue sets are provided to allow FreeRTOS to be integrated\r
+ * with legacy third party driver code.\r
+ *\r
+ * Note 2:  Blocking on a queue set that contains a mutex will not cause the\r
+ * mutex holder to inherit the priority of the blocked task.\r
+ *\r
+ * @param xQueueSet The queue set on which the task will (potentially) block.\r
+ *\r
+ * @param xBlockTimeTicks The maximum time, in ticks, that the calling task will\r
+ * remain in the Blocked state (with other tasks executing) to wait for a member\r
+ * of the queue set to be ready for a successful queue read or semaphore take\r
+ * operation.\r
+ *\r
+ * @return xQueueReadMultiple() will return the handle of a queue contained \r
+ * in the queue set that contains data, or the handle of a semaphore contained\r
+ * in the queue set that is available, or NULL if no such queue or semaphore \r
+ * exists before before the specified block time expires.\r
+ */\r
+xQueueHandle xQueueReadMultiple( xQueueSetHandle xQueueSet, portTickType xBlockTimeTicks );\r
+\r
 /* Not public API functions. */\r
 void vQueueWaitForMessageRestricted( xQueueHandle pxQueue, portTickType xTicksToWait );\r
 portBASE_TYPE xQueueGenericReset( xQueueHandle pxQueue, portBASE_TYPE xNewQueue );\r