\r
portBASE_TYPE xQueueGenericReset( xQueueHandle pxQueue, portBASE_TYPE xNewQueue )\r
{\r
-portBASE_TYPE xReturn = pdPASS;\r
-\r
configASSERT( pxQueue );\r
\r
- /* If the queue being reset has already been used (has not just been\r
- created), then only reset the queue if its event lists are empty. */\r
- if( xNewQueue != pdTRUE )\r
- {\r
- if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )\r
- {\r
- xReturn = pdFAIL;\r
- }\r
-\r
- if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE )\r
- {\r
- xReturn = pdFAIL;\r
- }\r
- }\r
-\r
- if( xReturn == pdPASS )\r
+ taskENTER_CRITICAL();\r
{\r
pxQueue->pcTail = pxQueue->pcHead + ( pxQueue->uxLength * pxQueue->uxItemSize );\r
pxQueue->uxMessagesWaiting = ( unsigned portBASE_TYPE ) 0U;\r
pxQueue->xRxLock = queueUNLOCKED;\r
pxQueue->xTxLock = queueUNLOCKED;\r
\r
- /* Ensure the event queues start with the correct state. */\r
- vListInitialise( &( pxQueue->xTasksWaitingToSend ) );\r
- vListInitialise( &( pxQueue->xTasksWaitingToReceive ) );\r
+ if( xNewQueue == pdFALSE )\r
+ {\r
+ /* If there are tasks blocked waiting to read from the queue, then \r
+ the tasks will remain blocked as after this function exits the queue \r
+ will still be empty. If there are tasks blocked waiting to write to \r
+ the queue, then one should be unblocked as after this function exits \r
+ it will be possible to write to it. */\r
+ if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE )\r
+ {\r
+ if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) == pdTRUE )\r
+ {\r
+ portYIELD_WITHIN_API();\r
+ }\r
+ }\r
+ }\r
+ else\r
+ {\r
+ /* Ensure the event queues start in the correct state. */\r
+ vListInitialise( &( pxQueue->xTasksWaitingToSend ) );\r
+ vListInitialise( &( pxQueue->xTasksWaitingToReceive ) ); \r
+ }\r
}\r
+ taskEXIT_CRITICAL();\r
\r
- return xReturn;\r
+ /* A value is returned for calling semantic consistency with previous\r
+ versions. */\r
+ return pdPASS;\r
}\r
/*-----------------------------------------------------------*/\r
\r
#endif /* configUSE_MUTEXES */\r
/*-----------------------------------------------------------*/\r
\r
-#if ( configUSE_MUTEXES == 1 )\r
+#if ( ( configUSE_MUTEXES == 1 ) && ( INCLUDE_xQueueGetMutexHolder == 1 ) )\r
\r
void* xQueueGetMutexHolder( xQueueHandle xSemaphore )\r
{\r
portYIELD_WITHIN_API();\r
}\r
}\r
-\r
}\r
\r
taskEXIT_CRITICAL();\r