]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Source/queue.c
Update version number to 9.0.0rc2.
[freertos] / FreeRTOS / Source / queue.c
index fe1ed0efa06cf8afdfaf93adeab78841eb336a6f..81f86d83649b95fd382c1372fd0b0d6a37f0f9ea 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-    FreeRTOS V9.0.0rc1 - Copyright (C) 2016 Real Time Engineers Ltd.\r
+    FreeRTOS V9.0.0rc2 - Copyright (C) 2016 Real Time Engineers Ltd.\r
     All rights reserved\r
 \r
     VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
@@ -947,6 +947,8 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
        {\r
                if( ( pxQueue->uxMessagesWaiting < pxQueue->uxLength ) || ( xCopyPosition == queueOVERWRITE ) )\r
                {\r
+                       const int8_t cTxLock = pxQueue->cTxLock;\r
+\r
                        traceQUEUE_SEND_FROM_ISR( pxQueue );\r
 \r
                        /* Semaphores use xQueueGiveFromISR(), so pxQueue will not be a\r
@@ -958,7 +960,7 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
 \r
                        /* The event list is not altered if the queue is locked.  This will\r
                        be done when the queue is unlocked later. */\r
-                       if( pxQueue->cTxLock == queueUNLOCKED )\r
+                       if( cTxLock == queueUNLOCKED )\r
                        {\r
                                #if ( configUSE_QUEUE_SETS == 1 )\r
                                {\r
@@ -1044,7 +1046,7 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
                        {\r
                                /* Increment the lock count so the task that unlocks the queue\r
                                knows that data was posted while it was locked. */\r
-                               ++( pxQueue->cTxLock );\r
+                               pxQueue->cTxLock = cTxLock + 1;\r
                        }\r
 \r
                        xReturn = pdPASS;\r
@@ -1102,11 +1104,15 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
 \r
        uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();\r
        {\r
+               const UBaseType_t uxMessagesWaiting = pxQueue->uxMessagesWaiting;\r
+\r
                /* When the queue is used to implement a semaphore no data is ever\r
                moved through the queue but it is still valid to see if the queue 'has\r
                space'. */\r
-               if( pxQueue->uxMessagesWaiting < pxQueue->uxLength )\r
+               if( uxMessagesWaiting < pxQueue->uxLength )\r
                {\r
+                       const int8_t cTxLock = pxQueue->cTxLock;\r
+\r
                        traceQUEUE_SEND_FROM_ISR( pxQueue );\r
 \r
                        /* A task can only have an inherited priority if it is a mutex\r
@@ -1115,11 +1121,11 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
                        can be assumed there is no mutex holder and no need to determine if\r
                        priority disinheritance is needed.  Simply increase the count of\r
                        messages (semaphores) available. */\r
-                       ++( pxQueue->uxMessagesWaiting );\r
+                       pxQueue->uxMessagesWaiting = uxMessagesWaiting + 1;\r
 \r
                        /* The event list is not altered if the queue is locked.  This will\r
                        be done when the queue is unlocked later. */\r
-                       if( pxQueue->cTxLock == queueUNLOCKED )\r
+                       if( cTxLock == queueUNLOCKED )\r
                        {\r
                                #if ( configUSE_QUEUE_SETS == 1 )\r
                                {\r
@@ -1205,7 +1211,7 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
                        {\r
                                /* Increment the lock count so the task that unlocks the queue\r
                                knows that data was posted while it was locked. */\r
-                               ++( pxQueue->cTxLock );\r
+                               pxQueue->cTxLock = cTxLock + 1;\r
                        }\r
 \r
                        xReturn = pdPASS;\r
@@ -1245,9 +1251,11 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
        {\r
                taskENTER_CRITICAL();\r
                {\r
+                       const UBaseType_t uxMessagesWaiting = pxQueue->uxMessagesWaiting;\r
+\r
                        /* Is there data in the queue now?  To be running the calling task\r
                        must be the highest priority task wanting to access the queue. */\r
-                       if( pxQueue->uxMessagesWaiting > ( UBaseType_t ) 0 )\r
+                       if( uxMessagesWaiting > ( UBaseType_t ) 0 )\r
                        {\r
                                /* Remember the read position in case the queue is only being\r
                                peeked. */\r
@@ -1260,7 +1268,7 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
                                        traceQUEUE_RECEIVE( pxQueue );\r
 \r
                                        /* Actually removing data, not just peeking. */\r
-                                       --( pxQueue->uxMessagesWaiting );\r
+                                       pxQueue->uxMessagesWaiting = uxMessagesWaiting - 1;\r
 \r
                                        #if ( configUSE_MUTEXES == 1 )\r
                                        {\r
@@ -1444,19 +1452,23 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
 \r
        uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();\r
        {\r
+               const UBaseType_t uxMessagesWaiting = pxQueue->uxMessagesWaiting;\r
+\r
                /* Cannot block in an ISR, so check there is data available. */\r
-               if( pxQueue->uxMessagesWaiting > ( UBaseType_t ) 0 )\r
+               if( uxMessagesWaiting > ( UBaseType_t ) 0 )\r
                {\r
+                       const int8_t cRxLock = pxQueue->cRxLock;\r
+\r
                        traceQUEUE_RECEIVE_FROM_ISR( pxQueue );\r
 \r
                        prvCopyDataFromQueue( pxQueue, pvBuffer );\r
-                       --( pxQueue->uxMessagesWaiting );\r
+                       pxQueue->uxMessagesWaiting = uxMessagesWaiting - 1;\r
 \r
                        /* If the queue is locked the event list will not be modified.\r
                        Instead update the lock count so the task that unlocks the queue\r
                        will know that an ISR has removed data while the queue was\r
                        locked. */\r
-                       if( pxQueue->cRxLock == queueUNLOCKED )\r
+                       if( cRxLock == queueUNLOCKED )\r
                        {\r
                                if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE )\r
                                {\r
@@ -1487,7 +1499,7 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
                        {\r
                                /* Increment the lock count so the task that unlocks the queue\r
                                knows that data was removed while it was locked. */\r
-                               ++( pxQueue->cRxLock );\r
+                               pxQueue->cRxLock = cRxLock + 1;\r
                        }\r
 \r
                        xReturn = pdPASS;\r
@@ -1673,6 +1685,11 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
 static BaseType_t prvCopyDataToQueue( Queue_t * const pxQueue, const void *pvItemToQueue, const BaseType_t xPosition )\r
 {\r
 BaseType_t xReturn = pdFALSE;\r
+UBaseType_t uxMessagesWaiting;\r
+\r
+       /* This function is called from a critical section. */\r
+\r
+       uxMessagesWaiting = pxQueue->uxMessagesWaiting;\r
 \r
        if( pxQueue->uxItemSize == ( UBaseType_t ) 0 )\r
        {\r
@@ -1719,13 +1736,13 @@ BaseType_t xReturn = pdFALSE;
 \r
                if( xPosition == queueOVERWRITE )\r
                {\r
-                       if( pxQueue->uxMessagesWaiting > ( UBaseType_t ) 0 )\r
+                       if( uxMessagesWaiting > ( UBaseType_t ) 0 )\r
                        {\r
                                /* An item is not being added but overwritten, so subtract\r
                                one from the recorded number of items in the queue so when\r
                                one is added again below the number of recorded items remains\r
                                correct. */\r
-                               --( pxQueue->uxMessagesWaiting );\r
+                               --uxMessagesWaiting;\r
                        }\r
                        else\r
                        {\r
@@ -1738,7 +1755,7 @@ BaseType_t xReturn = pdFALSE;
                }\r
        }\r
 \r
-       ++( pxQueue->uxMessagesWaiting );\r
+       pxQueue->uxMessagesWaiting = uxMessagesWaiting + 1;\r
 \r
        return xReturn;\r
 }\r
@@ -1772,8 +1789,10 @@ static void prvUnlockQueue( Queue_t * const pxQueue )
        updated. */\r
        taskENTER_CRITICAL();\r
        {\r
+               int8_t cTxLock = pxQueue->cTxLock;\r
+\r
                /* See if data was added to the queue while it was locked. */\r
-               while( pxQueue->cTxLock > queueLOCKED_UNMODIFIED )\r
+               while( cTxLock > queueLOCKED_UNMODIFIED )\r
                {\r
                        /* Data was posted while the queue was locked.  Are any tasks\r
                        blocked waiting for data to become available? */\r
@@ -1841,7 +1860,7 @@ static void prvUnlockQueue( Queue_t * const pxQueue )
                        }\r
                        #endif /* configUSE_QUEUE_SETS */\r
 \r
-                       --( pxQueue->cTxLock );\r
+                       --cTxLock;\r
                }\r
 \r
                pxQueue->cTxLock = queueUNLOCKED;\r
@@ -1851,7 +1870,9 @@ static void prvUnlockQueue( Queue_t * const pxQueue )
        /* Do the same for the Rx lock. */\r
        taskENTER_CRITICAL();\r
        {\r
-               while( pxQueue->cRxLock > queueLOCKED_UNMODIFIED )\r
+               int8_t cRxLock = pxQueue->cRxLock;\r
+\r
+               while( cRxLock > queueLOCKED_UNMODIFIED )\r
                {\r
                        if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE )\r
                        {\r
@@ -1864,7 +1885,7 @@ static void prvUnlockQueue( Queue_t * const pxQueue )
                                        mtCOVERAGE_TEST_MARKER();\r
                                }\r
 \r
-                               --( pxQueue->cRxLock );\r
+                               --cRxLock;\r
                        }\r
                        else\r
                        {\r
@@ -2262,7 +2283,7 @@ BaseType_t xReturn;
 \r
 #if ( configQUEUE_REGISTRY_SIZE > 0 )\r
 \r
-       const char *pcQueueGetQueueName( QueueHandle_t xQueue ) /*lint !e971 Unqualified char types are allowed for strings and single characters only. */\r
+       const char *pcQueueGetName( QueueHandle_t xQueue ) /*lint !e971 Unqualified char types are allowed for strings and single characters only. */\r
        {\r
        UBaseType_t ux;\r
        const char *pcReturn = NULL; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */\r
@@ -2479,12 +2500,14 @@ BaseType_t xReturn;
 \r
                if( pxQueueSetContainer->uxMessagesWaiting < pxQueueSetContainer->uxLength )\r
                {\r
+                       const int8_t cTxLock = pxQueueSetContainer->cTxLock;\r
+\r
                        traceQUEUE_SEND( pxQueueSetContainer );\r
 \r
                        /* The data copied is the handle of the queue that contains data. */\r
                        xReturn = prvCopyDataToQueue( pxQueueSetContainer, &pxQueue, xCopyPosition );\r
 \r
-                       if( pxQueueSetContainer->cTxLock == queueUNLOCKED )\r
+                       if( cTxLock == queueUNLOCKED )\r
                        {\r
                                if( listLIST_IS_EMPTY( &( pxQueueSetContainer->xTasksWaitingToReceive ) ) == pdFALSE )\r
                                {\r
@@ -2505,7 +2528,7 @@ BaseType_t xReturn;
                        }\r
                        else\r
                        {\r
-                               ( pxQueueSetContainer->cTxLock )++;\r
+                               pxQueueSetContainer->cTxLock = cTxLock + 1;\r
                        }\r
                }\r
                else\r