diff --git a/Source/include/FreeRTOS.h b/Source/include/FreeRTOS.h index 6c5e227d60..fb31e736ca 100644 --- a/Source/include/FreeRTOS.h +++ b/Source/include/FreeRTOS.h @@ -149,6 +149,10 @@ typedef portBASE_TYPE (*pdTASK_HOOK_CODE)( void * ); #define INCLUDE_xTimerGetTimerDaemonTaskHandle 0 #endif +#ifndef INCLUDE_xQueueGetMutexHolder + #define INCLUDE_xQueueGetMutexHolder 0 +#endif + #ifndef INCLUDE_pcTaskGetTaskName #define INCLUDE_pcTaskGetTaskName 0 #endif diff --git a/Source/portable/MSVC-MingW/port.c b/Source/portable/MSVC-MingW/port.c index 952817f681..a13e68fbfe 100644 --- a/Source/portable/MSVC-MingW/port.c +++ b/Source/portable/MSVC-MingW/port.c @@ -1,5 +1,5 @@ /* - FreeRTOS V7.1.1-rc1 - Copyright (C) 2011 Real Time Engineers Ltd. + FreeRTOS V7.1.1 - Copyright (C) 2011 Real Time Engineers Ltd. *************************************************************************** diff --git a/Source/portable/MSVC-MingW/portmacro.h b/Source/portable/MSVC-MingW/portmacro.h index 6de3c1f939..813aa732e9 100644 --- a/Source/portable/MSVC-MingW/portmacro.h +++ b/Source/portable/MSVC-MingW/portmacro.h @@ -1,5 +1,5 @@ /* - FreeRTOS V7.1.1-rc1 - Copyright (C) 2011 Real Time Engineers Ltd. + FreeRTOS V7.1.1 - Copyright (C) 2011 Real Time Engineers Ltd. *************************************************************************** diff --git a/Source/queue.c b/Source/queue.c index 355131c0dc..5faea1d2d3 100644 --- a/Source/queue.c +++ b/Source/queue.c @@ -278,26 +278,9 @@ static void prvCopyDataFromQueue( xQUEUE * const pxQueue, const void *pvBuffer ) portBASE_TYPE xQueueGenericReset( xQueueHandle pxQueue, portBASE_TYPE xNewQueue ) { -portBASE_TYPE xReturn = pdPASS; - configASSERT( pxQueue ); - /* If the queue being reset has already been used (has not just been - created), then only reset the queue if its event lists are empty. */ - if( xNewQueue != pdTRUE ) - { - if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) - { - xReturn = pdFAIL; - } - - if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE ) - { - xReturn = pdFAIL; - } - } - - if( xReturn == pdPASS ) + taskENTER_CRITICAL(); { pxQueue->pcTail = pxQueue->pcHead + ( pxQueue->uxLength * pxQueue->uxItemSize ); pxQueue->uxMessagesWaiting = ( unsigned portBASE_TYPE ) 0U; @@ -306,12 +289,33 @@ portBASE_TYPE xReturn = pdPASS; pxQueue->xRxLock = queueUNLOCKED; pxQueue->xTxLock = queueUNLOCKED; - /* Ensure the event queues start with the correct state. */ - vListInitialise( &( pxQueue->xTasksWaitingToSend ) ); - vListInitialise( &( pxQueue->xTasksWaitingToReceive ) ); + if( xNewQueue == pdFALSE ) + { + /* If there are tasks blocked waiting to read from the queue, then + the tasks will remain blocked as after this function exits the queue + will still be empty. If there are tasks blocked waiting to write to + the queue, then one should be unblocked as after this function exits + it will be possible to write to it. */ + if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE ) + { + if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) == pdTRUE ) + { + portYIELD_WITHIN_API(); + } + } + } + else + { + /* Ensure the event queues start in the correct state. */ + vListInitialise( &( pxQueue->xTasksWaitingToSend ) ); + vListInitialise( &( pxQueue->xTasksWaitingToReceive ) ); + } } + taskEXIT_CRITICAL(); - return xReturn; + /* A value is returned for calling semantic consistency with previous + versions. */ + return pdPASS; } /*-----------------------------------------------------------*/ @@ -425,7 +429,7 @@ xQueueHandle xReturn = NULL; #endif /* configUSE_MUTEXES */ /*-----------------------------------------------------------*/ -#if ( configUSE_MUTEXES == 1 ) +#if ( ( configUSE_MUTEXES == 1 ) && ( INCLUDE_xQueueGetMutexHolder == 1 ) ) void* xQueueGetMutexHolder( xQueueHandle xSemaphore ) { @@ -1024,7 +1028,6 @@ signed char *pcOriginalReadPosition; portYIELD_WITHIN_API(); } } - } taskEXIT_CRITICAL();