]> git.sur5r.net Git - freertos/commitdiff
Add in the portSET_INTERRUPT_MASK_FROM_ISR() and portCLEAR_INTERRUPT_MASK_FROM_ISR...
authorrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Wed, 7 May 2008 18:00:26 +0000 (18:00 +0000)
committerrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Wed, 7 May 2008 18:00:26 +0000 (18:00 +0000)
git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@343 1d2547de-c912-0410-9cb9-b8ca96c0e9e2

Source/queue.c

index 9c3003d3e90e4ff07b622c446d8f3fb6eef01ddd..b31893d3373f9856b5c881f9bd8722427178f538 100644 (file)
@@ -808,40 +808,44 @@ signed portBASE_TYPE xReturn;
        queue read, instead we return a flag to say whether a context switch is\r
        required or not (i.e. has a task with a higher priority than us been woken\r
        by this post). */\r
-       if( pxQueue->uxMessagesWaiting < pxQueue->uxLength )\r
+       portSET_INTERRUPT_MASK_FROM_ISR();\r
        {\r
-               traceQUEUE_SEND_FROM_ISR( pxQueue );\r
-\r
-               prvCopyDataToQueue( pxQueue, pvItemToQueue, xCopyPosition );\r
-\r
-               /* If the queue is locked we do not alter the event list.  This will\r
-               be done when the queue is unlocked later. */\r
-               if( pxQueue->xTxLock == queueUNLOCKED )\r
+               if( pxQueue->uxMessagesWaiting < pxQueue->uxLength )\r
                {\r
-                       if( !listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) )\r
+                       traceQUEUE_SEND_FROM_ISR( pxQueue );\r
+       \r
+                       prvCopyDataToQueue( pxQueue, pvItemToQueue, xCopyPosition );\r
+       \r
+                       /* If the queue is locked we do not alter the event list.  This will\r
+                       be done when the queue is unlocked later. */\r
+                       if( pxQueue->xTxLock == queueUNLOCKED )\r
                        {\r
-                               if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )\r
+                               if( !listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) )\r
                                {\r
-                                       /* The task waiting has a higher priority so record that a\r
-                                       context switch is required. */\r
-                                       *pxHigherPriorityTaskWoken = pdTRUE;\r
+                                       if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )\r
+                                       {\r
+                                               /* The task waiting has a higher priority so record that a\r
+                                               context switch is required. */\r
+                                               *pxHigherPriorityTaskWoken = pdTRUE;\r
+                                       }\r
                                }\r
                        }\r
+                       else\r
+                       {\r
+                               /* Increment the lock count so the task that unlocks the queue\r
+                               knows that data was posted while it was locked. */\r
+                               ++( pxQueue->xTxLock );\r
+                       }\r
+       \r
+                       xReturn = pdPASS;\r
                }\r
                else\r
                {\r
-                       /* Increment the lock count so the task that unlocks the queue\r
-                       knows that data was posted while it was locked. */\r
-                       ++( pxQueue->xTxLock );\r
+                       traceQUEUE_SEND_FROM_ISR_FAILED( pxQueue );\r
+                       xReturn = errQUEUE_FULL;\r
                }\r
-\r
-               xReturn = pdPASS;\r
-       }\r
-       else\r
-       {\r
-               traceQUEUE_SEND_FROM_ISR_FAILED( pxQueue );\r
-               xReturn = errQUEUE_FULL;\r
        }\r
+       portCLEAR_INTERRUPT_MASK_FROM_ISR();\r
 \r
        return xReturn;\r
 }\r
@@ -1004,43 +1008,47 @@ signed portBASE_TYPE xQueueReceiveFromISR( xQueueHandle pxQueue, void * const pv
 {\r
 signed portBASE_TYPE xReturn;\r
 \r
-       /* We cannot block from an ISR, so check there is data available. */\r
-       if( pxQueue->uxMessagesWaiting > ( unsigned portBASE_TYPE ) 0 )\r
+       portSET_INTERRUPT_MASK_FROM_ISR();\r
        {\r
-               traceQUEUE_RECEIVE_FROM_ISR( pxQueue );\r
-\r
-               prvCopyDataFromQueue( pxQueue, pvBuffer );\r
-               --( pxQueue->uxMessagesWaiting );\r
-\r
-               /* If the queue is locked we will not modify the event list.  Instead\r
-               we update the lock count so the task that unlocks the queue will know\r
-               that an ISR has removed data while the queue was locked. */\r
-               if( pxQueue->xRxLock == queueUNLOCKED )\r
+               /* We cannot block from an ISR, so check there is data available. */\r
+               if( pxQueue->uxMessagesWaiting > ( unsigned portBASE_TYPE ) 0 )\r
                {\r
-                       if( !listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) )\r
+                       traceQUEUE_RECEIVE_FROM_ISR( pxQueue );\r
+       \r
+                       prvCopyDataFromQueue( pxQueue, pvBuffer );\r
+                       --( pxQueue->uxMessagesWaiting );\r
+       \r
+                       /* If the queue is locked we will not modify the event list.  Instead\r
+                       we update the lock count so the task that unlocks the queue will know\r
+                       that an ISR has removed data while the queue was locked. */\r
+                       if( pxQueue->xRxLock == queueUNLOCKED )\r
                        {\r
-                               if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE )\r
+                               if( !listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) )\r
                                {\r
-                                       /* The task waiting has a higher priority than us so\r
-                                       force a context switch. */\r
-                                       *pxTaskWoken = pdTRUE;\r
+                                       if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE )\r
+                                       {\r
+                                               /* The task waiting has a higher priority than us so\r
+                                               force a context switch. */\r
+                                               *pxTaskWoken = pdTRUE;\r
+                                       }\r
                                }\r
                        }\r
+                       else\r
+                       {\r
+                               /* Increment the lock count so the task that unlocks the queue\r
+                               knows that data was removed while it was locked. */\r
+                               ++( pxQueue->xRxLock );\r
+                       }\r
+       \r
+                       xReturn = pdPASS;\r
                }\r
                else\r
                {\r
-                       /* Increment the lock count so the task that unlocks the queue\r
-                       knows that data was removed while it was locked. */\r
-                       ++( pxQueue->xRxLock );\r
+                       xReturn = pdFAIL;\r
+                       traceQUEUE_RECEIVE_FROM_ISR_FAILED( pxQueue );\r
                }\r
-\r
-               xReturn = pdPASS;\r
-       }\r
-       else\r
-       {\r
-               xReturn = pdFAIL;\r
-               traceQUEUE_RECEIVE_FROM_ISR_FAILED( pxQueue );\r
        }\r
+       portCLEAR_INTERRUPT_MASK_FROM_ISR();\r
 \r
        return xReturn;\r
 }\r