]> granicus.if.org Git - esp-idf/commitdiff
FreeRTOS: Add xQueueGetMutexHolder support
authorAngus Gratton <angus@espressif.com>
Wed, 24 Aug 2016 10:10:52 +0000 (18:10 +0800)
committerAngus Gratton <angus@espressif.com>
Wed, 24 Aug 2016 10:13:10 +0000 (18:13 +0800)
Enables it as a config option, but there's no overhead at all if the
function is not called anywhere.

components/freertos/include/freertos/FreeRTOSConfig.h
components/freertos/queue.c

index 46abb9a3b8589719fd43d7f745b358612cd1bf7a..e95abaa9ccd9b9949ee2f5e68648e65856e65560 100644 (file)
 #define INCLUDE_vTaskDelay                                     1
 #define INCLUDE_uxTaskGetStackHighWaterMark    1
 
+#define INCLUDE_xSemaphoreGetMutexHolder    1
+
 /* The priority at which the tick interrupt runs.  This should probably be
    kept at 1. */
 #define configKERNEL_INTERRUPT_PRIORITY                1
index 92e182a62094a4393d90028e3eb752b7a978aca5..248ae7c00a08e75a143c812f4e9924194793f762 100644 (file)
@@ -483,14 +483,15 @@ int8_t *pcAllocatedBuffer;
 
        void* xQueueGetMutexHolder( QueueHandle_t xSemaphore )
        {
-       void *pxReturn;
+               Queue_t * const pxQueue = ( Queue_t * ) xSemaphore;
+               void *pxReturn;
 
                /* This function is called by xSemaphoreGetMutexHolder(), and should not
                be called directly.  Note:  This is a good way of determining if the
                calling task is the mutex holder, but not a good way of determining the
                identity of the mutex holder, as the holder may change between the
                following critical section exiting and the function returning. */
-               taskENTER_CRITICAL();
+               taskENTER_CRITICAL(&pxQueue->mux);
                {
                        if( ( ( Queue_t * ) xSemaphore )->uxQueueType == queueQUEUE_IS_MUTEX )
                        {
@@ -501,7 +502,7 @@ int8_t *pcAllocatedBuffer;
                                pxReturn = NULL;
                        }
                }
-               taskEXIT_CRITICAL();
+               taskEXIT_CRITICAL(&pxQueue->mux);
 
                return pxReturn;
        } /*lint !e818 xSemaphore cannot be a pointer to const because it is a typedef. */