From: richardbarry Date: Thu, 17 May 2012 08:22:27 +0000 (+0000) Subject: Added INCLUDE_xQueueGetMutexHolder macro. X-Git-Tag: V7.2.0~21 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=8e72ee02c713b0d851853753b1310a81c226ddc7;p=freertos Added INCLUDE_xQueueGetMutexHolder macro. Removed the "-rc1" that was accidentally left on the version number of some Win32 port files. Changed the behaviour of xQueueGenericReset() so queues can be reset when tasks are blocked on them. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@1751 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- diff --git a/Source/include/FreeRTOS.h b/Source/include/FreeRTOS.h index 6c5e227d6..fb31e736c 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 952817f68..a13e68fbf 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 6de3c1f93..813aa732e 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 355131c0d..5faea1d2d 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();