]> git.sur5r.net Git - freertos/commitdiff
Create minor optimisations (just an asm instruction or two) by using consts in a...
authorrtel <rtel@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Tue, 29 Mar 2016 13:07:27 +0000 (13:07 +0000)
committerrtel <rtel@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Tue, 29 Mar 2016 13:07:27 +0000 (13:07 +0000)
Add the simple xTimerGetPeriod() and xTimerGetExpiryTime() functions.

git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@2432 1d2547de-c912-0410-9cb9-b8ca96c0e9e2

FreeRTOS/Source/include/timers.h
FreeRTOS/Source/portable/MSVC-MingW/port.c
FreeRTOS/Source/queue.c
FreeRTOS/Source/tasks.c
FreeRTOS/Source/timers.c

index b314539275e0bde282203fc951de264916cc8688..cbf9bc0b8026260dd52a86024a528606121894ea 100644 (file)
@@ -1266,6 +1266,32 @@ BaseType_t xTimerPendFunctionCall( PendedFunction_t xFunctionToPend, void *pvPar
  */\r
 const char * pcTimerGetTimerName( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */\r
 \r
+/**\r
+ * TickType_t xTimerGetPeriod( TimerHandle_t xTimer );\r
+ *\r
+ * Returns the period of a timer.\r
+ *\r
+ * @param xTimer The handle of the timer being queried.\r
+ *\r
+ * @return The period of the timer in ticks.\r
+ */\r
+TickType_t xTimerGetPeriod( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;\r
+\r
+/**\r
+* TickType_t xTimerGetExpiryTime( TimerHandle_t xTimer );\r
+*\r
+* Returns the time in ticks at which the timer will expire.  If this is less\r
+* than the current tick count then the expiry time has overflowed from the\r
+* current time.\r
+*\r
+* @param xTimer The handle of the timer being queried.\r
+*\r
+* @return If the timer is running then the time in ticks at which the timer\r
+* will next expire is returned.  If the timer is not running then the return\r
+* value is undefined.\r
+*/\r
+TickType_t xTimerGetExpiryTime( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;\r
+\r
 /*\r
  * Functions beyond this part are not part of the public API and are intended\r
  * for use by the kernel only.\r
index ad023f1eff4bfe861b5c6baad6a22a4c23cdeef2..08c50e9d5805759bbd64b85da751c091af6ec011 100644 (file)
@@ -88,13 +88,15 @@ Priorities are higher when a soak test is performed to lessen the effect of
 Windows interfering with the timing. */\r
 #define portSOAK_TEST\r
 #ifndef portSOAK_TEST\r
+       #define portDELETE_SELF_THREAD_PRIORITY                  THREAD_PRIORITY_HIGHEST /* Must be highest. */\r
        #define portSIMULATED_INTERRUPTS_THREAD_PRIORITY THREAD_PRIORITY_NORMAL\r
        #define portSIMULATED_TIMER_THREAD_PRIORITY              THREAD_PRIORITY_BELOW_NORMAL\r
        #define portTASK_THREAD_PRIORITY                                 THREAD_PRIORITY_IDLE\r
 #else\r
-       #define portSIMULATED_INTERRUPTS_THREAD_PRIORITY THREAD_PRIORITY_TIME_CRITICAL\r
-       #define portSIMULATED_TIMER_THREAD_PRIORITY              THREAD_PRIORITY_HIGHEST\r
-       #define portTASK_THREAD_PRIORITY                                 THREAD_PRIORITY_ABOVE_NORMAL\r
+       #define portDELETE_SELF_THREAD_PRIORITY                  THREAD_PRIORITY_TIME_CRITICAL /* Must be highest. */\r
+       #define portSIMULATED_INTERRUPTS_THREAD_PRIORITY THREAD_PRIORITY_HIGHEST\r
+       #define portSIMULATED_TIMER_THREAD_PRIORITY              THREAD_PRIORITY_ABOVE_NORMAL\r
+       #define portTASK_THREAD_PRIORITY                                 THREAD_PRIORITY_NORMAL\r
 #endif\r
 /*\r
  * Created as a high priority thread, this function uses a timer to simulate\r
@@ -516,7 +518,7 @@ uint32_t ulErrorCode;
        does not run and swap it out before it is closed.  If that were to happen\r
        the thread would never run again and effectively be a thread handle and\r
        memory leak. */\r
-       SetThreadPriority( pvThread, THREAD_PRIORITY_HIGHEST );\r
+       SetThreadPriority( pvThread, portDELETE_SELF_THREAD_PRIORITY );\r
 \r
        /* This function will not return, therefore a yield is set as pending to\r
        ensure a context switch occurs away from this thread on the next tick. */\r
index fe1ed0efa06cf8afdfaf93adeab78841eb336a6f..5f35f55bcb7301ed0678df297f00278156d8f12d 100644 (file)
@@ -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
@@ -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
index fdcc8f349df0369f698e599965c97b929d0ee536..a93fedcdf01d8e5e01e5d52131c727fe1548493c 100644 (file)
@@ -153,16 +153,19 @@ functions but without including stdio.h here. */
 \r
        #define taskSELECT_HIGHEST_PRIORITY_TASK()                                                                                                                      \\r
        {                                                                                                                                                                                                       \\r
+       UBaseType_t uxTopPriority = uxTopReadyPriority;                                                                                                         \\r
+                                                                                                                                                                                                               \\r
                /* Find the highest priority queue that contains ready tasks. */                                                                \\r
-               while( listLIST_IS_EMPTY( &( pxReadyTasksLists[ uxTopReadyPriority ] ) ) )                                              \\r
+               while( listLIST_IS_EMPTY( &( pxReadyTasksLists[ uxTopPriority ] ) ) )                                                   \\r
                {                                                                                                                                                                                               \\r
-                       configASSERT( uxTopReadyPriority );                                                                                                                     \\r
-                       --uxTopReadyPriority;                                                                                                                                           \\r
+                       configASSERT( uxTopPriority );                                                                                                                          \\r
+                       --uxTopPriority;                                                                                                                                                        \\r
                }                                                                                                                                                                                               \\r
                                                                                                                                                                                                                \\r
                /* listGET_OWNER_OF_NEXT_ENTRY indexes through the list, so the tasks of                                                \\r
                the     same priority get an equal share of the processor time. */                                                                      \\r
-               listGET_OWNER_OF_NEXT_ENTRY( pxCurrentTCB, &( pxReadyTasksLists[ uxTopReadyPriority ] ) );              \\r
+               listGET_OWNER_OF_NEXT_ENTRY( pxCurrentTCB, &( pxReadyTasksLists[ uxTopPriority ] ) );                   \\r
+               uxTopReadyPriority = uxTopPriority;                                                                                                                             \\r
        } /* taskSELECT_HIGHEST_PRIORITY_TASK */\r
 \r
        /*-----------------------------------------------------------*/\r
@@ -354,7 +357,7 @@ PRIVILEGED_DATA static List_t * volatile pxDelayedTaskList;                         /*< Points to the
 PRIVILEGED_DATA static List_t * volatile pxOverflowDelayedTaskList;            /*< Points to the delayed task list currently being used to hold tasks that have overflowed the current tick count. */\r
 PRIVILEGED_DATA static List_t xPendingReadyList;                                               /*< Tasks that have been readied while the scheduler was suspended.  They will be moved to the ready list when the scheduler is resumed. */\r
 \r
-#if( ( INCLUDE_vTaskDelete == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )\r
+#if( INCLUDE_vTaskDelete == 1 )\r
 \r
        PRIVILEGED_DATA static List_t xTasksWaitingTermination;                         /*< Tasks that have been deleted - but their memory not yet freed. */\r
        PRIVILEGED_DATA static volatile UBaseType_t uxDeletedTasksWaitingCleanUp = ( UBaseType_t ) 0U;\r
@@ -559,12 +562,11 @@ static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB ) PRIVILEGED_FUNCTION;
                configASSERT( puxStackBuffer != NULL );\r
                configASSERT( pxTaskBuffer != NULL );\r
 \r
-               /* The memory used for the task's TCB and stack are passed into this\r
-               function - use them. */\r
-               pxNewTCB = ( TCB_t * ) pxTaskBuffer; /*lint !e740 Unusual cast is ok as the structures are designed to have the same alignment, and the size is checked by an assert. */\r
-\r
-               if( pxNewTCB != NULL )\r
+               if( ( pxTaskBuffer != NULL ) && ( puxStackBuffer != NULL ) )\r
                {\r
+                       /* The memory used for the task's TCB and stack are passed into this\r
+                       function - use them. */\r
+                       pxNewTCB = ( TCB_t * ) pxTaskBuffer; /*lint !e740 Unusual cast is ok as the structures are designed to have the same alignment, and the size is checked by an assert. */\r
                        pxNewTCB->pxStack = ( StackType_t * ) puxStackBuffer;\r
 \r
                        #if( configSUPPORT_DYNAMIC_ALLOCATION == 1 )\r
@@ -1955,24 +1957,30 @@ BaseType_t xAlreadyYielded = pdFALSE;
                                they should be processed now.  This ensures the tick count does\r
                                not     slip, and that any delayed tasks are resumed at the correct\r
                                time. */\r
-                               if( uxPendedTicks > ( UBaseType_t ) 0U )\r
                                {\r
-                                       while( uxPendedTicks > ( UBaseType_t ) 0U )\r
+                                       UBaseType_t uxPendedCounts = uxPendedTicks; /* Non-volatile copy. */\r
+\r
+                                       if( uxPendedCounts > ( UBaseType_t ) 0U )\r
                                        {\r
-                                               if( xTaskIncrementTick() != pdFALSE )\r
-                                               {\r
-                                                       xYieldPending = pdTRUE;\r
-                                               }\r
-                                               else\r
+                                               do\r
                                                {\r
-                                                       mtCOVERAGE_TEST_MARKER();\r
-                                               }\r
-                                               --uxPendedTicks;\r
+                                                       if( xTaskIncrementTick() != pdFALSE )\r
+                                                       {\r
+                                                               xYieldPending = pdTRUE;\r
+                                                       }\r
+                                                       else\r
+                                                       {\r
+                                                               mtCOVERAGE_TEST_MARKER();\r
+                                                       }\r
+                                                       --uxPendedCounts;\r
+                                               } while( uxPendedCounts > ( UBaseType_t ) 0U );\r
+\r
+                                               uxPendedTicks = 0;\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
                                        }\r
-                               }\r
-                               else\r
-                               {\r
-                                       mtCOVERAGE_TEST_MARKER();\r
                                }\r
 \r
                                if( xYieldPending != pdFALSE )\r
@@ -2389,103 +2397,101 @@ BaseType_t xSwitchRequired = pdFALSE;
        traceTASK_INCREMENT_TICK( xTickCount );\r
        if( uxSchedulerSuspended == ( UBaseType_t ) pdFALSE )\r
        {\r
+               /* Minor optimisation.  The tick count cannot change in this\r
+               block. */\r
+               const TickType_t xConstTickCount = xTickCount + 1;\r
+\r
                /* Increment the RTOS tick, switching the delayed and overflowed\r
                delayed lists if it wraps to 0. */\r
-               ++xTickCount;\r
+               xTickCount = xConstTickCount;\r
 \r
+               if( xConstTickCount == ( TickType_t ) 0U )\r
                {\r
-                       /* Minor optimisation.  The tick count cannot change in this\r
-                       block. */\r
-                       const TickType_t xConstTickCount = xTickCount;\r
-\r
-                       if( xConstTickCount == ( TickType_t ) 0U )\r
-                       {\r
-                               taskSWITCH_DELAYED_LISTS();\r
-                       }\r
-                       else\r
-                       {\r
-                               mtCOVERAGE_TEST_MARKER();\r
-                       }\r
+                       taskSWITCH_DELAYED_LISTS();\r
+               }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
 \r
-                       /* See if this tick has made a timeout expire.  Tasks are stored in\r
-                       the     queue in the order of their wake time - meaning once one task\r
-                       has been found whose block time has not expired there is no need to\r
-                       look any further down the list. */\r
-                       if( xConstTickCount >= xNextTaskUnblockTime )\r
+               /* See if this tick has made a timeout expire.  Tasks are stored in\r
+               the     queue in the order of their wake time - meaning once one task\r
+               has been found whose block time has not expired there is no need to\r
+               look any further down the list. */\r
+               if( xConstTickCount >= xNextTaskUnblockTime )\r
+               {\r
+                       for( ;; )\r
                        {\r
-                               for( ;; )\r
+                               if( listLIST_IS_EMPTY( pxDelayedTaskList ) != pdFALSE )\r
+                               {\r
+                                       /* The delayed list is empty.  Set xNextTaskUnblockTime\r
+                                       to the maximum possible value so it is extremely\r
+                                       unlikely that the\r
+                                       if( xTickCount >= xNextTaskUnblockTime ) test will pass\r
+                                       next time through. */\r
+                                       xNextTaskUnblockTime = portMAX_DELAY; /*lint !e961 MISRA exception as the casts are only redundant for some ports. */\r
+                                       break;\r
+                               }\r
+                               else\r
                                {\r
-                                       if( listLIST_IS_EMPTY( pxDelayedTaskList ) != pdFALSE )\r
+                                       /* The delayed list is not empty, get the value of the\r
+                                       item at the head of the delayed list.  This is the time\r
+                                       at which the task at the head of the delayed list must\r
+                                       be removed from the Blocked state. */\r
+                                       pxTCB = ( TCB_t * ) listGET_OWNER_OF_HEAD_ENTRY( pxDelayedTaskList );\r
+                                       xItemValue = listGET_LIST_ITEM_VALUE( &( pxTCB->xStateListItem ) );\r
+\r
+                                       if( xConstTickCount < xItemValue )\r
                                        {\r
-                                               /* The delayed list is empty.  Set xNextTaskUnblockTime\r
-                                               to the maximum possible value so it is extremely\r
-                                               unlikely that the\r
-                                               if( xTickCount >= xNextTaskUnblockTime ) test will pass\r
-                                               next time through. */\r
-                                               xNextTaskUnblockTime = portMAX_DELAY; /*lint !e961 MISRA exception as the casts are only redundant for some ports. */\r
+                                               /* It is not time to unblock this item yet, but the\r
+                                               item value is the time at which the task at the head\r
+                                               of the blocked list must be removed from the Blocked\r
+                                               state - so record the item value in\r
+                                               xNextTaskUnblockTime. */\r
+                                               xNextTaskUnblockTime = xItemValue;\r
                                                break;\r
                                        }\r
                                        else\r
                                        {\r
-                                               /* The delayed list is not empty, get the value of the\r
-                                               item at the head of the delayed list.  This is the time\r
-                                               at which the task at the head of the delayed list must\r
-                                               be removed from the Blocked state. */\r
-                                               pxTCB = ( TCB_t * ) listGET_OWNER_OF_HEAD_ENTRY( pxDelayedTaskList );\r
-                                               xItemValue = listGET_LIST_ITEM_VALUE( &( pxTCB->xStateListItem ) );\r
-\r
-                                               if( xConstTickCount < xItemValue )\r
-                                               {\r
-                                                       /* It is not time to unblock this item yet, but the\r
-                                                       item value is the time at which the task at the head\r
-                                                       of the blocked list must be removed from the Blocked\r
-                                                       state - so record the item value in\r
-                                                       xNextTaskUnblockTime. */\r
-                                                       xNextTaskUnblockTime = xItemValue;\r
-                                                       break;\r
-                                               }\r
-                                               else\r
-                                               {\r
-                                                       mtCOVERAGE_TEST_MARKER();\r
-                                               }\r
+                                               mtCOVERAGE_TEST_MARKER();\r
+                                       }\r
+\r
+                                       /* It is time to remove the item from the Blocked state. */\r
+                                       ( void ) uxListRemove( &( pxTCB->xStateListItem ) );\r
+\r
+                                       /* Is the task waiting on an event also?  If so remove\r
+                                       it from the event list. */\r
+                                       if( listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) ) != NULL )\r
+                                       {\r
+                                               ( void ) uxListRemove( &( pxTCB->xEventListItem ) );\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
+                                       }\r
 \r
-                                               /* It is time to remove the item from the Blocked state. */\r
-                                               ( void ) uxListRemove( &( pxTCB->xStateListItem ) );\r
+                                       /* Place the unblocked task into the appropriate ready\r
+                                       list. */\r
+                                       prvAddTaskToReadyList( pxTCB );\r
 \r
-                                               /* Is the task waiting on an event also?  If so remove\r
-                                               it from the event list. */\r
-                                               if( listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) ) != NULL )\r
+                                       /* A task being unblocked cannot cause an immediate\r
+                                       context switch if preemption is turned off. */\r
+                                       #if (  configUSE_PREEMPTION == 1 )\r
+                                       {\r
+                                               /* Preemption is on, but a context switch should\r
+                                               only be performed if the unblocked task has a\r
+                                               priority that is equal to or higher than the\r
+                                               currently executing task. */\r
+                                               if( pxTCB->uxPriority >= pxCurrentTCB->uxPriority )\r
                                                {\r
-                                                       ( void ) uxListRemove( &( pxTCB->xEventListItem ) );\r
+                                                       xSwitchRequired = pdTRUE;\r
                                                }\r
                                                else\r
                                                {\r
                                                        mtCOVERAGE_TEST_MARKER();\r
                                                }\r
-\r
-                                               /* Place the unblocked task into the appropriate ready\r
-                                               list. */\r
-                                               prvAddTaskToReadyList( pxTCB );\r
-\r
-                                               /* A task being unblocked cannot cause an immediate\r
-                                               context switch if preemption is turned off. */\r
-                                               #if (  configUSE_PREEMPTION == 1 )\r
-                                               {\r
-                                                       /* Preemption is on, but a context switch should\r
-                                                       only be performed if the unblocked task has a\r
-                                                       priority that is equal to or higher than the\r
-                                                       currently executing task. */\r
-                                                       if( pxTCB->uxPriority >= pxCurrentTCB->uxPriority )\r
-                                                       {\r
-                                                               xSwitchRequired = pdTRUE;\r
-                                                       }\r
-                                                       else\r
-                                                       {\r
-                                                               mtCOVERAGE_TEST_MARKER();\r
-                                                       }\r
-                                               }\r
-                                               #endif /* configUSE_PREEMPTION */\r
                                        }\r
+                                       #endif /* configUSE_PREEMPTION */\r
                                }\r
                        }\r
                }\r
@@ -3248,7 +3254,7 @@ UBaseType_t uxPriority;
 static void prvCheckTasksWaitingTermination( void )\r
 {\r
 \r
-       /** THIS FUNCTION IS CALLED FROM  THE RTOS IDLE TASK **/\r
+       /** THIS FUNCTION IS CALLED FROM THE RTOS IDLE TASK **/\r
 \r
        #if ( INCLUDE_vTaskDelete == 1 )\r
        {\r
@@ -4111,7 +4117,7 @@ TickType_t uxReturn;
                                }\r
                                else\r
                                {\r
-                                       ( pxCurrentTCB->ulNotifiedValue )--;\r
+                                       pxCurrentTCB->ulNotifiedValue = ulReturn - 1;\r
                                }\r
                        }\r
                        else\r
@@ -4563,6 +4569,7 @@ TickType_t uxReturn;
 static void prvAddCurrentTaskToDelayedList( TickType_t xTicksToWait, const BaseType_t xCanBlockIndefinitely )\r
 {\r
 TickType_t xTimeToWake;\r
+const TickType_t xConstTickCount = xTickCount;\r
 \r
        #if( INCLUDE_xTaskAbortDelay == 1 )\r
        {\r
@@ -4586,7 +4593,6 @@ TickType_t xTimeToWake;
                mtCOVERAGE_TEST_MARKER();\r
        }\r
 \r
-\r
        #if ( INCLUDE_vTaskSuspend == 1 )\r
        {\r
                if( ( xTicksToWait == portMAX_DELAY ) && ( xCanBlockIndefinitely != pdFALSE ) )\r
@@ -4601,12 +4607,12 @@ TickType_t xTimeToWake;
                        /* Calculate the time at which the task should be woken if the event\r
                        does not occur.  This may overflow but this doesn't matter, the\r
                        kernel will manage it correctly. */\r
-                       xTimeToWake = xTickCount + xTicksToWait;\r
+                       xTimeToWake = xConstTickCount + xTicksToWait;\r
 \r
                        /* The list item will be inserted in wake time order. */\r
                        listSET_LIST_ITEM_VALUE( &( pxCurrentTCB->xStateListItem ), xTimeToWake );\r
 \r
-                       if( xTimeToWake < xTickCount )\r
+                       if( xTimeToWake < xConstTickCount )\r
                        {\r
                                /* Wake time has overflowed.  Place this item in the overflow\r
                                list. */\r
@@ -4637,12 +4643,12 @@ TickType_t xTimeToWake;
                /* Calculate the time at which the task should be woken if the event\r
                does not occur.  This may overflow but this doesn't matter, the kernel\r
                will manage it correctly. */\r
-               xTimeToWake = xTickCount + xTicksToWait;\r
+               xTimeToWake = xConstTickCount + xTicksToWait;\r
 \r
                /* The list item will be inserted in wake time order. */\r
                listSET_LIST_ITEM_VALUE( &( pxCurrentTCB->xStateListItem ), xTimeToWake );\r
 \r
-               if( xTimeToWake < xTickCount )\r
+               if( xTimeToWake < xConstTickCount )\r
                {\r
                        /* Wake time has overflowed.  Place this item in the overflow list. */\r
                        vListInsert( pxOverflowDelayedTaskList, &( pxCurrentTCB->xStateListItem ) );\r
index 6e5a341aa40fe1e6886de28f0af25204155b6b74..cd4df8a3d18d760d28853c020085bd6b3a870c43 100644 (file)
@@ -433,6 +433,26 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void )
 }\r
 /*-----------------------------------------------------------*/\r
 \r
+TickType_t xTimerGetPeriod( TimerHandle_t xTimer )\r
+{\r
+const Timer_t * const pxTimer = ( const Timer_t * const  ) xTimer;\r
+\r
+       configASSERT( xTimer );\r
+       return pxTimer->xTimerPeriodInTicks;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+TickType_t xTimerGetExpiryTime( TimerHandle_t xTimer )\r
+{\r
+const Timer_t * const pxTimer = ( const Timer_t * const  ) xTimer;\r
+TickType_t xReturn;\r
+\r
+       configASSERT( xTimer );\r
+       xReturn = listGET_LIST_ITEM_VALUE( &( pxTimer->xTimerListItem ) );\r
+       return xReturn;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
 const char * pcTimerGetTimerName( TimerHandle_t xTimer ) /*lint !e971 Unqualified char types are allowed for strings and single characters only. */\r
 {\r
 Timer_t *pxTimer = ( Timer_t * ) xTimer;\r