| 1463 | /*-----------------------------------------------------------*/ |
| 1464 | |
| 1465 | BaseType_t xQueueSemaphoreTake( QueueHandle_t xQueue, |
| 1466 | TickType_t xTicksToWait ) |
| 1467 | { |
| 1468 | BaseType_t xEntryTimeSet = pdFALSE; |
| 1469 | TimeOut_t xTimeOut; |
| 1470 | Queue_t * const pxQueue = xQueue; |
| 1471 | |
| 1472 | #if ( configUSE_MUTEXES == 1 ) |
| 1473 | BaseType_t xInheritanceOccurred = pdFALSE; |
| 1474 | #endif |
| 1475 | |
| 1476 | /* Check the queue pointer is not NULL. */ |
| 1477 | configASSERT( ( pxQueue ) ); |
| 1478 | |
| 1479 | /* Check this really is a semaphore, in which case the item size will be |
| 1480 | * 0. */ |
| 1481 | configASSERT( pxQueue->uxItemSize == 0 ); |
| 1482 | |
| 1483 | /* Cannot block if the scheduler is suspended. */ |
| 1484 | #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) ) |
| 1485 | { |
| 1486 | configASSERT( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) ); |
| 1487 | } |
| 1488 | #endif |
| 1489 | |
| 1490 | /*lint -save -e904 This function relaxes the coding standard somewhat to allow return |
| 1491 | * statements within the function itself. This is done in the interest |
| 1492 | * of execution time efficiency. */ |
| 1493 | for( ; ; ) |
| 1494 | { |
| 1495 | taskENTER_CRITICAL(); |
| 1496 | { |
| 1497 | /* Semaphores are queues with an item size of 0, and where the |
| 1498 | * number of messages in the queue is the semaphore's count value. */ |
| 1499 | const UBaseType_t uxSemaphoreCount = pxQueue->uxMessagesWaiting; |
| 1500 | |
| 1501 | /* Is there data in the queue now? To be running the calling task |
| 1502 | * must be the highest priority task wanting to access the queue. */ |
| 1503 | if( uxSemaphoreCount > ( UBaseType_t ) 0 ) |
| 1504 | { |
| 1505 | traceQUEUE_RECEIVE( pxQueue ); |
| 1506 | |
| 1507 | /* Semaphores are queues with a data size of zero and where the |
| 1508 | * messages waiting is the semaphore's count. Reduce the count. */ |
| 1509 | pxQueue->uxMessagesWaiting = uxSemaphoreCount - ( UBaseType_t ) 1; |
| 1510 | |
| 1511 | #if ( configUSE_MUTEXES == 1 ) |
| 1512 | { |
| 1513 | if( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX ) |
| 1514 | { |
| 1515 | /* Record the information required to implement |
| 1516 | * priority inheritance should it become necessary. */ |
| 1517 | pxQueue->u.xSemaphore.xMutexHolder = pvTaskIncrementMutexHeldCount(); |
| 1518 | } |
| 1519 | else |
| 1520 | { |
| 1521 | mtCOVERAGE_TEST_MARKER(); |
| 1522 | } |
no test coverage detected