]> git.sur5r.net Git - freertos/commitdiff
Remove initialisation of xQueueRegistry.
authorrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Thu, 14 Aug 2008 11:09:26 +0000 (11:09 +0000)
committerrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Thu, 14 Aug 2008 11:09:26 +0000 (11:09 +0000)
git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@455 1d2547de-c912-0410-9cb9-b8ca96c0e9e2

Source/queue.c

index dd58ef12a3631bcd0a4969e7f6d6eaf6948178aa..0c23f31fdd817644d8af71173ff15e9a94a820e0 100644 (file)
        Please ensure to read the configuration and relevant port sections of the\r
        online documentation.\r
 \r
-       http://www.FreeRTOS.org - Documentation, latest information, license and \r
+       http://www.FreeRTOS.org - Documentation, latest information, license and\r
        contact details.\r
 \r
-       http://www.SafeRTOS.com - A version that is certified for use in safety \r
+       http://www.SafeRTOS.com - A version that is certified for use in safety\r
        critical systems.\r
 \r
-       http://www.OpenRTOS.com - Commercial support, development, porting, \r
+       http://www.OpenRTOS.com - Commercial support, development, porting,\r
        licensing and training services.\r
 */\r
 \r
@@ -149,9 +149,9 @@ unsigned portBASE_TYPE uxQueueMessagesWaitingFromISR( const xQueueHandle pxQueue
  * queue structures.  It has no other purpose so is an optional component.\r
  */\r
 #if configQUEUE_REGISTRY_SIZE > 0\r
-       \r
+\r
        /* The type stored within the queue registry array.  This allows a name\r
-       to be assigned to each queue making kernel aware debugging a little \r
+       to be assigned to each queue making kernel aware debugging a little\r
        more user friendly. */\r
        typedef struct QUEUE_REGISTRY_ITEM\r
        {\r
@@ -162,16 +162,14 @@ unsigned portBASE_TYPE uxQueueMessagesWaitingFromISR( const xQueueHandle pxQueue
        /* The queue registry is simply an array of xQueueRegistryItem structures.\r
        The pcQueueName member of a structure being NULL is indicative of the\r
        array position being vacant. */\r
-       xQueueRegistryItem xQueueRegistry[ configQUEUE_REGISTRY_SIZE ] = { 0 };\r
+       xQueueRegistryItem xQueueRegistry[ configQUEUE_REGISTRY_SIZE ];\r
 \r
        /* Removes a queue from the registry by simply setting the pcQueueName\r
        member to NULL. */\r
        static void vQueueUnregisterQueue( xQueueHandle xQueue );\r
        void vQueueAddToRegistry( xQueueHandle xQueue, signed portCHAR *pcQueueName );\r
-\r
 #endif\r
 \r
-\r
 /*\r
  * Unlocks a queue locked by a call to prvLockQueue.  Locking a queue does not\r
  * prevent an ISR from adding or removing items to the queue, but does prevent\r
@@ -290,7 +288,7 @@ size_t xQueueSizeInBytes;
        xQueueHandle xQueueCreateMutex( void )\r
        {\r
        xQUEUE *pxNewQueue;\r
-       \r
+\r
                /* Allocate the new queue structure. */\r
                pxNewQueue = ( xQUEUE * ) pvPortMalloc( sizeof( xQUEUE ) );\r
                if( pxNewQueue != NULL )\r
@@ -298,12 +296,12 @@ size_t xQueueSizeInBytes;
                        /* Information required for priority inheritance. */\r
                        pxNewQueue->pxMutexHolder = NULL;\r
                        pxNewQueue->uxQueueType = queueQUEUE_IS_MUTEX;\r
-       \r
+\r
                        /* Queues used as a mutex no data is actually copied into or out\r
                        of the queue. */\r
                        pxNewQueue->pcWriteTo = NULL;\r
                        pxNewQueue->pcReadFrom = NULL;\r
-                       \r
+\r
                        /* Each mutex has a length of 1 (like a binary semaphore) and\r
                        an item size of 0 as nothing is actually copied into or out\r
                        of the mutex. */\r
@@ -312,7 +310,7 @@ size_t xQueueSizeInBytes;
                        pxNewQueue->uxItemSize = 0;\r
                        pxNewQueue->xRxLock = queueUNLOCKED;\r
                        pxNewQueue->xTxLock = queueUNLOCKED;\r
-       \r
+\r
                        /* Ensure the event queues start with the correct state. */\r
                        vListInitialise( &( pxNewQueue->xTasksWaitingToSend ) );\r
                        vListInitialise( &( pxNewQueue->xTasksWaitingToReceive ) );\r
@@ -326,7 +324,7 @@ size_t xQueueSizeInBytes;
                {\r
                        traceCREATE_MUTEX_FAILED();\r
                }\r
-       \r
+\r
                return pxNewQueue;\r
        }\r
 \r
@@ -364,7 +362,7 @@ size_t xQueueSizeInBytes;
                 xQueueGenericSend( pxMutex, NULL, queueMUTEX_GIVE_BLOCK_TIME, queueSEND_TO_BACK );\r
                        }\r
 \r
-                       xReturn = pdPASS;                       \r
+                       xReturn = pdPASS;\r
                }\r
                else\r
                {\r
@@ -406,7 +404,7 @@ size_t xQueueSizeInBytes;
                        {\r
                                ( pxMutex->uxRecursiveCallCount )++;\r
                        }\r
-               }               \r
+               }\r
 \r
                return xReturn;\r
        }\r
@@ -419,7 +417,7 @@ size_t xQueueSizeInBytes;
        xQueueHandle xQueueCreateCountingSemaphore( unsigned portBASE_TYPE uxCountValue, unsigned portBASE_TYPE uxInitialCount )\r
        {\r
        xQueueHandle pxHandle;\r
-       \r
+\r
                pxHandle = xQueueCreate( ( unsigned portBASE_TYPE ) uxCountValue, queueSEMAPHORE_QUEUE_ITEM_LENGTH );\r
 \r
                if( pxHandle != NULL )\r
@@ -470,14 +468,14 @@ xTimeOutType xTimeOut;
                                {\r
                                        traceBLOCKING_ON_QUEUE_SEND( pxQueue );\r
                                        vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToSend ), xTicksToWait );\r
-                                               \r
+\r
                                        /* Unlocking the queue means queue events can effect the\r
                                        event list.  It is possible     that interrupts occurring now\r
                                        remove this task from the event list again - but as the\r
                                        scheduler is suspended the task will go onto the pending\r
                                        ready last instead of the actual ready list. */\r
                                        prvUnlockQueue( pxQueue );\r
-                                               \r
+\r
                                        /* Resuming the scheduler will move tasks from the pending\r
                                        ready list into the ready list - so it is feasible that this\r
                                        task is already in a ready list before it yields - in which\r
@@ -502,11 +500,11 @@ xTimeOutType xTimeOut;
                                ( void ) xTaskResumeAll();\r
                        }\r
                }\r
-                       \r
+\r
                /* Higher priority tasks and interrupts can execute during\r
                this time and could possible refill the queue - even if we\r
                unblocked because space became available. */\r
-               \r
+\r
                taskENTER_CRITICAL();\r
                {\r
                        /* Is there room on the queue now?  To be running we must be\r
@@ -516,7 +514,7 @@ xTimeOutType xTimeOut;
                                traceQUEUE_SEND( pxQueue );\r
                                prvCopyDataToQueue( pxQueue, pvItemToQueue, xCopyPosition );\r
                                xReturn = pdPASS;\r
-                                       \r
+\r
                                /* If there was a task waiting for data to arrive on the\r
                                queue then unblock it now. */\r
                                if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )\r
@@ -574,7 +572,7 @@ xTimeOutType xTimeOut;
        xTimeOutType xTimeOut;\r
 \r
                /* The source code that implements the alternative (Alt) API is\r
-               simpler because it makes more use of critical sections.  This is        \r
+               simpler because it makes more use of critical sections.  This is\r
                the approach taken by many other RTOSes, but FreeRTOS.org has the\r
                preferred fully featured API too.  The fully featured API has more\r
                complex code that takes longer to execute, but makes less use of\r
@@ -595,7 +593,7 @@ xTimeOutType xTimeOut;
                                                block at least once. */\r
                                                vTaskSetTimeOutState( &xTimeOut );\r
                                        }\r
-                                       \r
+\r
                                        if( prvIsQueueFull( pxQueue ) )\r
                                        {\r
                                        /* Need to call xTaskCheckForTimeout again as time could\r
@@ -614,11 +612,11 @@ xTimeOutType xTimeOut;
                                }\r
                                portEXIT_CRITICAL();\r
                        }\r
-                               \r
+\r
                        /* Higher priority tasks and interrupts can execute during\r
                        this time and could possible refill the queue - even if we\r
                        unblocked because space became available. */\r
-                       \r
+\r
                        taskENTER_CRITICAL();\r
                        {\r
                                /* Is there room on the queue now?  To be running we must be\r
@@ -628,7 +626,7 @@ xTimeOutType xTimeOut;
                                        traceQUEUE_SEND( pxQueue );\r
                                        prvCopyDataToQueue( pxQueue, pvItemToQueue, xCopyPosition );\r
                                        xReturn = pdPASS;\r
-                                               \r
+\r
                                        /* If there was a task waiting for data to arrive on the\r
                                        queue then unblock it now. */\r
                                        if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )\r
@@ -689,7 +687,7 @@ xTimeOutType xTimeOut;
        signed portCHAR *pcOriginalReadPosition;\r
 \r
                /* The source code that implements the alternative (Alt) API is\r
-               simpler because it makes more use of critical sections.  This is        \r
+               simpler because it makes more use of critical sections.  This is\r
                the approach taken by many other RTOSes, but FreeRTOS.org has the\r
                preferred fully featured API too.  The fully featured API has more\r
                complex code that takes longer to execute, but makes less use of\r
@@ -709,7 +707,7 @@ xTimeOutType xTimeOut;
                                                block at least once. */\r
                                                vTaskSetTimeOutState( &xTimeOut );\r
                                        }\r
-                                       \r
+\r
                                        if( prvIsQueueEmpty( pxQueue ) )\r
                                        {\r
                                        /* Need to call xTaskCheckForTimeout again as time could\r
@@ -735,7 +733,7 @@ xTimeOutType xTimeOut;
                                }\r
                                portEXIT_CRITICAL();\r
                        }\r
-               \r
+\r
                        taskENTER_CRITICAL();\r
                        {\r
                                if( pxQueue->uxMessagesWaiting > ( unsigned portBASE_TYPE ) 0 )\r
@@ -762,7 +760,7 @@ xTimeOutType xTimeOut;
                                                        }\r
                                                }\r
                                                #endif\r
-                                                       \r
+\r
                                                if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE )\r
                                                {\r
                                                        if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) == pdTRUE )\r
@@ -790,11 +788,11 @@ xTimeOutType xTimeOut;
                                                                /* The task waiting has a higher priority that this task. */\r
                                                                taskYIELD();\r
                                                        }\r
-                                               }                       \r
+                                               }\r
 \r
                                        }\r
-                                       \r
-                                       xReturn = pdPASS;                                       \r
+\r
+                                       xReturn = pdPASS;\r
                                }\r
                                else\r
                                {\r
@@ -845,9 +843,9 @@ unsigned portBASE_TYPE uxSavedInterruptStatus;
                if( pxQueue->uxMessagesWaiting < pxQueue->uxLength )\r
                {\r
                        traceQUEUE_SEND_FROM_ISR( pxQueue );\r
-       \r
+\r
                        prvCopyDataToQueue( pxQueue, pvItemToQueue, xCopyPosition );\r
-       \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
@@ -868,7 +866,7 @@ unsigned portBASE_TYPE uxSavedInterruptStatus;
                                knows that data was posted while it was locked. */\r
                                ++( pxQueue->xTxLock );\r
                        }\r
-       \r
+\r
                        xReturn = pdPASS;\r
                }\r
                else\r
@@ -944,9 +942,13 @@ signed portCHAR *pcOriginalReadPosition;
                                ( void ) xTaskResumeAll();\r
                        }\r
                }\r
-       \r
+\r
+/* The two tasks are blocked on the queue, the low priority task is polling/running. */\r
+\r
+/* An interrupt occurs here - which unblocks the HP tasks, but they do not run. */\r
                taskENTER_CRITICAL();\r
                {\r
+/* Because the interrupt occurred the LP task manages to grab the data as the other two tasks are not yet running. */\r
                        if( pxQueue->uxMessagesWaiting > ( unsigned portBASE_TYPE ) 0 )\r
                        {\r
                                /* Remember our read position in case we are just peeking. */\r
@@ -971,7 +973,7 @@ signed portCHAR *pcOriginalReadPosition;
                                                }\r
                                        }\r
                                        #endif\r
-                                               \r
+\r
                                        if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE )\r
                                        {\r
                                                if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) == pdTRUE )\r
@@ -996,14 +998,14 @@ signed portCHAR *pcOriginalReadPosition;
                                                the pending ready list as the scheduler is still suspended. */\r
                                                if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )\r
                                                {\r
-                                                       /* The task waiting has a higher priority that this task. */\r
+                                                       /* The task waiting has a higher priority than this task. */\r
                                                        taskYIELD();\r
                                                }\r
-                                       }                       \r
+                                       }\r
 \r
                                }\r
-                               \r
-                               xReturn = pdPASS;                                       \r
+\r
+                               xReturn = pdPASS;\r
                        }\r
                        else\r
                        {\r
@@ -1030,6 +1032,7 @@ signed portCHAR *pcOriginalReadPosition;
                                traceQUEUE_RECEIVE_FAILED( pxQueue );\r
                        }\r
                }\r
+\r
        } while( xReturn == queueERRONEOUS_UNBLOCK );\r
 \r
        return xReturn;\r
@@ -1047,10 +1050,10 @@ unsigned portBASE_TYPE uxSavedInterruptStatus;
                if( pxQueue->uxMessagesWaiting > ( unsigned portBASE_TYPE ) 0 )\r
                {\r
                        traceQUEUE_RECEIVE_FROM_ISR( pxQueue );\r
-       \r
+\r
                        prvCopyDataFromQueue( pxQueue, pvBuffer );\r
                        --( pxQueue->uxMessagesWaiting );\r
-       \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
@@ -1072,7 +1075,7 @@ unsigned portBASE_TYPE uxSavedInterruptStatus;
                                knows that data was removed while it was locked. */\r
                                ++( pxQueue->xRxLock );\r
                        }\r
-       \r
+\r
                        xReturn = pdPASS;\r
                }\r
                else\r
@@ -1149,7 +1152,7 @@ static void prvCopyDataToQueue( xQUEUE *pxQueue, const void *pvItemToQueue, port
                if( pxQueue->pcReadFrom < pxQueue->pcHead )\r
                {\r
                        pxQueue->pcReadFrom = ( pxQueue->pcTail - pxQueue->uxItemSize );\r
-               }               \r
+               }\r
        }\r
 \r
        ++( pxQueue->uxMessagesWaiting );\r
@@ -1166,7 +1169,7 @@ static void prvCopyDataFromQueue( xQUEUE * const pxQueue, const void *pvBuffer )
                        pxQueue->pcReadFrom = pxQueue->pcHead;\r
                }\r
                memcpy( ( void * ) pvBuffer, ( void * ) pxQueue->pcReadFrom, ( unsigned ) pxQueue->uxItemSize );\r
-       }       \r
+       }\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
@@ -1282,7 +1285,7 @@ signed portBASE_TYPE xReturn;
 signed portBASE_TYPE xQueueCRSend( xQueueHandle pxQueue, const void *pvItemToQueue, portTickType xTicksToWait )\r
 {\r
 signed portBASE_TYPE xReturn;\r
-               \r
+\r
        /* If the queue is already full we may have to block.  A critical section\r
        is required to prevent an interrupt removing something from the queue\r
        between the check to see if the queue is full and blocking on the queue. */\r
@@ -1296,7 +1299,7 @@ signed portBASE_TYPE xReturn;
                        {\r
                                /* As this is called from a coroutine we cannot block directly, but\r
                                return indicating that we need to block. */\r
-                               vCoRoutineAddToDelayedList( xTicksToWait, &( pxQueue->xTasksWaitingToSend ) );                          \r
+                               vCoRoutineAddToDelayedList( xTicksToWait, &( pxQueue->xTasksWaitingToSend ) );\r
                                portENABLE_INTERRUPTS();\r
                                return errQUEUE_BLOCKED;\r
                        }\r
@@ -1308,14 +1311,14 @@ signed portBASE_TYPE xReturn;
                }\r
        }\r
        portENABLE_INTERRUPTS();\r
-               \r
+\r
        portNOP();\r
 \r
        portDISABLE_INTERRUPTS();\r
        {\r
                if( pxQueue->uxMessagesWaiting < pxQueue->uxLength )\r
                {\r
-                       /* There is room in the queue, copy the data into the queue. */                 \r
+                       /* There is room in the queue, copy the data into the queue. */\r
                        prvCopyDataToQueue( pxQueue, pvItemToQueue, queueSEND_TO_BACK );\r
                        xReturn = pdPASS;\r
 \r
@@ -1359,7 +1362,7 @@ signed portBASE_TYPE xReturn;
                if( pxQueue->uxMessagesWaiting == ( unsigned portBASE_TYPE ) 0 )\r
                {\r
                        /* There are no messages in the queue, do we want to block or just\r
-                       leave with nothing? */                  \r
+                       leave with nothing? */\r
                        if( xTicksToWait > ( portTickType ) 0 )\r
                        {\r
                                /* As this is a co-routine we cannot block directly, but return\r
@@ -1405,7 +1408,7 @@ signed portBASE_TYPE xReturn;
                                {\r
                                        xReturn = errQUEUE_YIELD;\r
                                }\r
-                       }       \r
+                       }\r
                }\r
                else\r
                {\r
@@ -1432,7 +1435,7 @@ signed portBASE_TYPE xQueueCRSendFromISR( xQueueHandle pxQueue, const void *pvIt
 \r
                /* We only want to wake one co-routine per ISR, so check that a\r
                co-routine has not already been woken. */\r
-               if( !xCoRoutinePreviouslyWoken )                \r
+               if( !xCoRoutinePreviouslyWoken )\r
                {\r
                        if( !listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) )\r
                        {\r
@@ -1529,7 +1532,7 @@ signed portBASE_TYPE xReturn;
                                xQueueRegistry[ ux ].pcQueueName = NULL;\r
                                break;\r
                        }\r
-               }       \r
+               }\r
        }\r
 \r
 #endif\r