FreeRTOS: Add xQueueGetMutexHolder support

Enables it as a config option, but there's no overhead at all if the
function is not called anywhere.
This commit is contained in:
Angus Gratton
2016-08-24 18:10:52 +08:00
parent 4b281af0f7
commit f5715ac28d
2 changed files with 6 additions and 3 deletions

View File

@@ -222,6 +222,8 @@
#define INCLUDE_vTaskDelay 1 #define INCLUDE_vTaskDelay 1
#define INCLUDE_uxTaskGetStackHighWaterMark 1 #define INCLUDE_uxTaskGetStackHighWaterMark 1
#define INCLUDE_xSemaphoreGetMutexHolder 1
/* The priority at which the tick interrupt runs. This should probably be /* The priority at which the tick interrupt runs. This should probably be
kept at 1. */ kept at 1. */
#define configKERNEL_INTERRUPT_PRIORITY 1 #define configKERNEL_INTERRUPT_PRIORITY 1

View File

@@ -483,6 +483,7 @@ int8_t *pcAllocatedBuffer;
void* xQueueGetMutexHolder( QueueHandle_t xSemaphore ) void* xQueueGetMutexHolder( QueueHandle_t xSemaphore )
{ {
Queue_t * const pxQueue = ( Queue_t * ) xSemaphore;
void *pxReturn; void *pxReturn;
/* This function is called by xSemaphoreGetMutexHolder(), and should not /* This function is called by xSemaphoreGetMutexHolder(), and should not
@@ -490,7 +491,7 @@ int8_t *pcAllocatedBuffer;
calling task is the mutex holder, but not a good way of determining 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 identity of the mutex holder, as the holder may change between the
following critical section exiting and the function returning. */ following critical section exiting and the function returning. */
taskENTER_CRITICAL(); taskENTER_CRITICAL(&pxQueue->mux);
{ {
if( ( ( Queue_t * ) xSemaphore )->uxQueueType == queueQUEUE_IS_MUTEX ) if( ( ( Queue_t * ) xSemaphore )->uxQueueType == queueQUEUE_IS_MUTEX )
{ {
@@ -501,7 +502,7 @@ int8_t *pcAllocatedBuffer;
pxReturn = NULL; pxReturn = NULL;
} }
} }
taskEXIT_CRITICAL(); taskEXIT_CRITICAL(&pxQueue->mux);
return pxReturn; return pxReturn;
} /*lint !e818 xSemaphore cannot be a pointer to const because it is a typedef. */ } /*lint !e818 xSemaphore cannot be a pointer to const because it is a typedef. */