]> git.sur5r.net Git - freertos/commitdiff
Clear up a few compiler warnings.
authorrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Mon, 7 Oct 2013 12:06:17 +0000 (12:06 +0000)
committerrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Mon, 7 Oct 2013 12:06:17 +0000 (12:06 +0000)
Correct header comments in the UARTCommandConsole.c file used in the SmartFusion2 demo.
Exercise the new xQueueSpacesAvailable() function in the MSVC demo.
Add defaults for the new traceMALLOC and traceFREE trace macros.
Catch tasks trying to exit their functions in the Cortex-M0 ports.
Add additional comments to timers.c in response to a support forum question.
Initialise _impure_ptr prior to the first task being started.
Prior to V7.5.0 a yield pended in the tick hook would have occurred during the same tick interrupt.  Return pdTRUE from xTaskIncrementTick() if a yield is pending to revert to that behaviour.

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

FreeRTOS/Demo/CORTEX_SmartFusion2_M2S050_SoftConsole/RTOSDemo/Full-Demo/UARTCommandConsole.c
FreeRTOS/Demo/Common/Minimal/BlockQ.c
FreeRTOS/Demo/Common/Minimal/QueueSet.c
FreeRTOS/Demo/WIN32-MSVC/main_full.c
FreeRTOS/Source/include/FreeRTOS.h
FreeRTOS/Source/portable/GCC/ARM_CM0/port.c
FreeRTOS/Source/portable/IAR/ARM_CM0/port.c
FreeRTOS/Source/portable/RVDS/ARM_CM0/port.c
FreeRTOS/Source/tasks.c
FreeRTOS/Source/timers.c

index 73aa0178e31c910b9b5a1f81dfda55957dbc78ae..fe54b0ed5e06dfa0ac62af0947652d2e9bd80477 100644 (file)
@@ -1,54 +1,65 @@
 /*\r
-    FreeRTOS V7.1.0 - Copyright (C) 2011 Real Time Engineers Ltd.\r
+    FreeRTOS V7.5.2 - Copyright (C) 2013 Real Time Engineers Ltd.\r
 \r
+    VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
 \r
     ***************************************************************************\r
      *                                                                       *\r
-     *    FreeRTOS tutorial books are available in pdf and paperback.        *\r
-     *    Complete, revised, and edited pdf reference manuals are also       *\r
-     *    available.                                                         *\r
+     *    FreeRTOS provides completely free yet professionally developed,    *\r
+     *    robust, strictly quality controlled, supported, and cross          *\r
+     *    platform software that has become a de facto standard.             *\r
      *                                                                       *\r
-     *    Purchasing FreeRTOS documentation will not only help you, by       *\r
-     *    ensuring you get running as quickly as possible and with an        *\r
-     *    in-depth knowledge of how to use FreeRTOS, it will also help       *\r
-     *    the FreeRTOS project to continue with its mission of providing     *\r
-     *    professional grade, cross platform, de facto standard solutions    *\r
-     *    for microcontrollers - completely free of charge!                  *\r
+     *    Help yourself get started quickly and support the FreeRTOS         *\r
+     *    project by purchasing a FreeRTOS tutorial book, reference          *\r
+     *    manual, or both from: http://www.FreeRTOS.org/Documentation        *\r
      *                                                                       *\r
-     *    >>> See http://www.FreeRTOS.org/Documentation for details. <<<     *\r
-     *                                                                       *\r
-     *    Thank you for using FreeRTOS, and thank you for your support!      *\r
+     *    Thank you!                                                         *\r
      *                                                                       *\r
     ***************************************************************************\r
 \r
-\r
     This file is part of the FreeRTOS distribution.\r
 \r
     FreeRTOS is free software; you can redistribute it and/or modify it under\r
     the terms of the GNU General Public License (version 2) as published by the\r
-    Free Software Foundation AND MODIFIED BY the FreeRTOS exception.\r
-    >>>NOTE<<< The modification to the GPL is included to allow you to\r
-    distribute a combined work that includes FreeRTOS without being obliged to\r
-    provide the source code for proprietary components outside of the FreeRTOS\r
-    kernel.  FreeRTOS is distributed in the hope that it will be useful, but\r
-    WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\r
-    or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for\r
-    more details. You should have received a copy of the GNU General Public\r
-    License and the FreeRTOS license exception along with FreeRTOS; if not it\r
-    can be viewed here: http://www.freertos.org/a00114.html and also obtained\r
-    by writing to Richard Barry, contact details for whom are available on the\r
-    FreeRTOS WEB site.\r
+    Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.\r
+\r
+    >>! NOTE: The modification to the GPL is included to allow you to distribute\r
+    >>! a combined work that includes FreeRTOS without being obliged to provide\r
+    >>! the source code for proprietary components outside of the FreeRTOS\r
+    >>! kernel.\r
+\r
+    FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
+    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
+    FOR A PARTICULAR PURPOSE.  Full license text is available from the following\r
+    link: http://www.freertos.org/a00114.html\r
 \r
     1 tab == 4 spaces!\r
 \r
-    http://www.FreeRTOS.org - Documentation, latest information, license and\r
-    contact details.\r
+    ***************************************************************************\r
+     *                                                                       *\r
+     *    Having a problem?  Start by reading the FAQ "My application does   *\r
+     *    not run, what could be wrong?"                                     *\r
+     *                                                                       *\r
+     *    http://www.FreeRTOS.org/FAQHelp.html                               *\r
+     *                                                                       *\r
+    ***************************************************************************\r
+\r
+    http://www.FreeRTOS.org - Documentation, books, training, latest versions,\r
+    license and Real Time Engineers Ltd. contact details.\r
 \r
-    http://www.SafeRTOS.com - A version that is certified for use in safety\r
-    critical systems.\r
+    http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
+    including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
+    compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
 \r
-    http://www.OpenRTOS.com - Commercial support, development, porting,\r
-    licensing and training services.\r
+    http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High\r
+    Integrity Systems to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
+    licenses offer ticketed support, indemnification and middleware.\r
+\r
+    http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
+    engineered and independently SIL3 certified version for use in safety and\r
+    mission critical applications that require provable dependability.\r
+\r
+    1 tab == 4 spaces!\r
 */\r
 \r
 /* Standard includes. */\r
index 43f5ac70c069bfd7370ee79b4c789f578a2b6b14..ee51b8b5e9615e4f0e5c3f75ef80189c82e0cdcb 100644 (file)
  *\r
  */\r
 \r
-/*\r
-\r
-Changes from V4.1.1\r
-\r
-       + The second set of tasks were created the wrong way around.  This has been\r
-         corrected.\r
-*/\r
-\r
-\r
 #include <stdlib.h>\r
 \r
 /* Scheduler include files. */\r
index b1c40c173082c21952053d66ba6195f4a369f4fa..b38df3c2e36579a5772f81fc969d85c8b7ee83c8 100644 (file)
@@ -387,6 +387,9 @@ static void prvQueueSetReceivingTask( void *pvParameters )
 unsigned long ulReceived;\r
 xQueueHandle xActivatedQueue;\r
 \r
+       /* Remove compiler warnings. */\r
+       ( void ) pvParameters;\r
+\r
        /* Create the queues and add them to the queue set before resuming the Tx\r
        task. */\r
        prvSetupTest();\r
index a08b3dcdb621fd28de184649d677dfdd3b42de27..308d55cfd9bb148c43fb921af786e63c1cf21789 100644 (file)
@@ -161,6 +161,11 @@ static void prvTestTask( void *pvParameters );
  */\r
 static void prvDemonstrateTaskStateAndHandleGetFunctions( void );\r
 \r
+/*\r
+ * A task to demonstrate the use of the xQueueSpacesAvailable() function.\r
+ */\r
+static void prvDemoQueueSpaceFunctions( void *pvParameters );\r
+\r
 /*-----------------------------------------------------------*/\r
 \r
 /* The variable into which error messages are latched. */\r
@@ -190,7 +195,8 @@ int main_full( void )
        vStartCountingSemaphoreTasks();\r
        vStartDynamicPriorityTasks();\r
        vStartQueueSetTasks();\r
-       vStartQueueOverwriteTask( mainQUEUE_OVERWRITE_PRIORITY );\r
+       vStartQueueOverwriteTask( mainQUEUE_OVERWRITE_PRIORITY );       \r
+       xTaskCreate( prvDemoQueueSpaceFunctions, ( signed char * ) "QSpace", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );\r
 \r
        /* The suicide tasks must be created last as they need to know how many\r
        tasks were running prior to their creation.  This then allows them to \r
@@ -453,4 +459,69 @@ xTaskHandle xTestTask;
 }\r
 /*-----------------------------------------------------------*/\r
 \r
+static void prvDemoQueueSpaceFunctions( void *pvParameters )\r
+{\r
+xQueueHandle xQueue = NULL;\r
+const unsigned portBASE_TYPE uxQueueLength = 10;\r
+unsigned portBASE_TYPE uxReturn, x;\r
+\r
+       /* Remove compiler warnings. */\r
+       ( void ) pvParameters;\r
+\r
+       /* Create the queue that will be used.  Nothing is actually going to be\r
+       sent or received so the queue item size is set to 0. */\r
+       xQueue = xQueueCreate( uxQueueLength, 0 );\r
+       configASSERT( xQueue );\r
+\r
+       for( ;; )\r
+       {\r
+               for( x = 0; x < uxQueueLength; x++ )\r
+               {\r
+                       /* Ask how many messages are available... */\r
+                       uxReturn = uxQueueMessagesWaiting( xQueue );\r
+                       \r
+                       /* Check the number of messages being reported as being available\r
+                       is as expected, and force an assert if not. */\r
+                       if( uxReturn != x )\r
+                       {\r
+                               /* xQueue cannot be NULL so this is deliberately causing an\r
+                               assert to be triggered as there is an error. */\r
+                               configASSERT( xQueue == NULL );\r
+                       }\r
+\r
+                       /* Ask how many spaces remain in the queue... */\r
+                       uxReturn = uxQueueSpacesAvailable( xQueue );\r
+                       \r
+                       /* Check the number of spaces being reported as being available\r
+                       is as expected, and force an assert if not. */\r
+                       if( uxReturn != ( uxQueueLength - x ) )\r
+                       {\r
+                               /* xQueue cannot be NULL so this is deliberately causing an\r
+                               assert to be triggered as there is an error. */\r
+                               configASSERT( xQueue == NULL );\r
+                       }\r
+\r
+                       /* Fill one more space in the queue. */\r
+                       xQueueSendToBack( xQueue, NULL, 0 );\r
+               }\r
+\r
+               /* Perform the same check while the queue is full. */\r
+               uxReturn = uxQueueMessagesWaiting( xQueue );\r
+               if( uxReturn != uxQueueLength )\r
+               {\r
+                       configASSERT( xQueue == NULL );\r
+               }\r
+\r
+               uxReturn = uxQueueSpacesAvailable( xQueue );\r
+                       \r
+               if( uxReturn != 0 )\r
+               {\r
+                       configASSERT( xQueue == NULL );\r
+               }\r
+\r
+               /* The queue is full, start again. */\r
+               xQueueReset( xQueue );\r
+       }\r
+}\r
+\r
 \r
index ee0a186cf51018fd3ac96bfb5df38b4730bb5516..7b84e0a80fa73fc986540ae5d7e2207b9761c11e 100644 (file)
@@ -511,6 +511,14 @@ typedef portBASE_TYPE (*pdTASK_HOOK_CODE)( void * );
        #define traceTIMER_COMMAND_RECEIVED( pxTimer, xMessageID, xMessageValue )\r
 #endif\r
 \r
+#ifndef traceMALLOC\r
+    #define traceMALLOC( pvAddress, uiSize )\r
+#endif\r
+\r
+#ifndef traceFREE\r
+    #define traceFREE( pvAddress, uiSize )\r
+#endif\r
+\r
 #ifndef configGENERATE_RUN_TIME_STATS\r
        #define configGENERATE_RUN_TIME_STATS 0\r
 #endif\r
index 6966c848efaf9d188fb29d6ad034676b2864299b..5aef176cf8abd3d5b80d796fa9e618dc50a2c573 100644 (file)
@@ -107,6 +107,11 @@ void vPortSVCHandler( void ) __attribute__ (( naked ));
  */\r
 static void vPortStartFirstTask( void ) __attribute__ (( naked ));\r
 \r
+/*\r
+ * Used to catch tasks that attempt to return from their implementing function.\r
+ */\r
+static void prvTaskExitError( void );\r
+\r
 /*-----------------------------------------------------------*/\r
 \r
 /*\r
@@ -120,7 +125,9 @@ portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE
        *pxTopOfStack = portINITIAL_XPSR;       /* xPSR */\r
        pxTopOfStack--;\r
        *pxTopOfStack = ( portSTACK_TYPE ) pxCode;      /* PC */\r
-       pxTopOfStack -= 6;      /* LR, R12, R3..R1 */\r
+       pxTopOfStack--;\r
+       *pxTopOfStack = ( portSTACK_TYPE ) prvTaskExitError;    /* LR */\r
+       pxTopOfStack -= 5;      /* R12, R3, R2 and R1. */\r
        *pxTopOfStack = ( portSTACK_TYPE ) pvParameters;        /* R0 */\r
        pxTopOfStack -= 8; /* R11..R4. */\r
 \r
@@ -128,6 +135,20 @@ portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE
 }\r
 /*-----------------------------------------------------------*/\r
 \r
+static void prvTaskExitError( void )\r
+{\r
+       /* A function that implements a task must not exit or attempt to return to\r
+       its caller as there is nothing to return to.  If a task wants to exit it \r
+       should instead call vTaskDelete( NULL ).\r
+       \r
+       Artificially force an assert() to be triggered if configASSERT() is \r
+       defined, then stop here so application writers can catch the error. */\r
+       configASSERT( uxCriticalNesting == ~0UL );\r
+       portDISABLE_INTERRUPTS();       \r
+       for( ;; );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
 void vPortSVCHandler( void )\r
 {\r
        __asm volatile (\r
@@ -250,6 +271,9 @@ void vClearInterruptMaskFromISR( unsigned long ulMask )
                                        " msr PRIMASK, r0       \n"\r
                                        " bx lr                           "\r
                                  );\r
+                                 \r
+       /* Just to avoid compiler warning. */\r
+       ( void ) ulMask;\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
index 6b3cc4162fa1e6af74a5e1c6a87a910ed5abfcbb..bf5b33469e6a71e342e920ed8efbfc01e166b757 100644 (file)
@@ -113,6 +113,11 @@ void xPortSysTickHandler( void );
  */\r
 extern void vPortStartFirstTask( void );\r
 \r
+/*\r
+ * Used to catch tasks that attempt to return from their implementing function.\r
+ */\r
+static void prvTaskExitError( void );\r
+\r
 /*-----------------------------------------------------------*/\r
 \r
 /*\r
@@ -126,7 +131,9 @@ portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE
        *pxTopOfStack = portINITIAL_XPSR;       /* xPSR */\r
        pxTopOfStack--;\r
        *pxTopOfStack = ( portSTACK_TYPE ) pxCode;      /* PC */\r
-       pxTopOfStack -= 6;      /* LR, R12, R3..R1 */\r
+       pxTopOfStack--;\r
+       *pxTopOfStack = ( portSTACK_TYPE ) prvTaskExitError;    /* LR */\r
+       pxTopOfStack -= 5;      /* R12, R3, R2 and R1. */\r
        *pxTopOfStack = ( portSTACK_TYPE ) pvParameters;        /* R0 */\r
        pxTopOfStack -= 8; /* R11..R4. */\r
 \r
@@ -134,6 +141,20 @@ portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE
 }\r
 /*-----------------------------------------------------------*/\r
 \r
+static void prvTaskExitError( void )\r
+{\r
+       /* A function that implements a task must not exit or attempt to return to\r
+       its caller as there is nothing to return to.  If a task wants to exit it \r
+       should instead call vTaskDelete( NULL ).\r
+       \r
+       Artificially force an assert() to be triggered if configASSERT() is \r
+       defined, then stop here so application writers can catch the error. */\r
+       configASSERT( uxCriticalNesting == ~0UL );\r
+       portDISABLE_INTERRUPTS();       \r
+       for( ;; );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
 /*\r
  * See header file for description.\r
  */\r
index 2c0169f7ea96dc129c7e2b6cb859e4c169edbc46..86bbc7b13237daf66fe151f55182db13939794b1 100644 (file)
@@ -110,6 +110,11 @@ void vPortSVCHandler( void );
  */\r
 static void prvPortStartFirstTask( void );\r
 \r
+/*\r
+ * Used to catch tasks that attempt to return from their implementing function.\r
+ */\r
+static void prvTaskExitError( void );\r
+\r
 /*-----------------------------------------------------------*/\r
 \r
 /*\r
@@ -123,7 +128,9 @@ portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE
        *pxTopOfStack = portINITIAL_XPSR;       /* xPSR */\r
        pxTopOfStack--;\r
        *pxTopOfStack = ( portSTACK_TYPE ) pxCode;      /* PC */\r
-       pxTopOfStack -= 6;      /* LR, R12, R3..R1 */\r
+       pxTopOfStack--;\r
+       *pxTopOfStack = ( portSTACK_TYPE ) prvTaskExitError;    /* LR */\r
+       pxTopOfStack -= 5;      /* R12, R3, R2 and R1. */\r
        *pxTopOfStack = ( portSTACK_TYPE ) pvParameters;        /* R0 */\r
        pxTopOfStack -= 8; /* R11..R4. */\r
 \r
@@ -131,6 +138,20 @@ portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE
 }\r
 /*-----------------------------------------------------------*/\r
 \r
+static void prvTaskExitError( void )\r
+{\r
+       /* A function that implements a task must not exit or attempt to return to\r
+       its caller as there is nothing to return to.  If a task wants to exit it \r
+       should instead call vTaskDelete( NULL ).\r
+       \r
+       Artificially force an assert() to be triggered if configASSERT() is \r
+       defined, then stop here so application writers can catch the error. */\r
+       configASSERT( uxCriticalNesting == ~0UL );\r
+       portDISABLE_INTERRUPTS();       \r
+       for( ;; );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
 __asm void vPortSVCHandler( void )\r
 {\r
        extern pxCurrentTCB;\r
index 417ccd42a7d2c2578c2f2ce74ce9a2c313350bdd..3590729641cf608a3cf909ca5f7d61a94eeee583 100644 (file)
@@ -89,7 +89,7 @@ privileged Vs unprivileged linkage and placement. */
        uxTaskGetSystemState() function.  Note the formatting functions are provided\r
        for convenience only, and are NOT considered part of the kernel. */\r
        #include <stdio.h>\r
-#endif /* ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS == 1 ) ) */\r
+#endif /* configUSE_STATS_FORMATTING_FUNCTIONS == 1 ) */\r
 \r
 /* Sanity check the configuration. */\r
 #if configUSE_TICKLESS_IDLE != 0\r
@@ -1196,7 +1196,11 @@ tskTCB * pxNewTCB;
 \r
                                if( uxSchedulerSuspended == ( unsigned portBASE_TYPE ) pdFALSE )\r
                                {\r
-                                       xYieldRequired = ( pxTCB->uxPriority >= pxCurrentTCB->uxPriority );\r
+                                       if( pxTCB->uxPriority >= pxCurrentTCB->uxPriority )\r
+                                       {\r
+                                               xYieldRequired = pdTRUE;\r
+                                       }\r
+\r
                                        ( void ) uxListRemove(  &( pxTCB->xGenericListItem ) );\r
                                        prvAddTaskToReadyList( pxTCB );\r
                                }\r
@@ -1250,12 +1254,17 @@ portBASE_TYPE xReturn;
                before or during the call to xPortStartScheduler().  The stacks of\r
                the created tasks contain a status word with interrupts switched on\r
                so interrupts will automatically get re-enabled when the first task\r
-               starts to run.\r
-\r
-               STEPPING THROUGH HERE USING A DEBUGGER CAN CAUSE BIG PROBLEMS IF THE\r
-               DEBUGGER ALLOWS INTERRUPTS TO BE PROCESSED. */\r
+               starts to run. */\r
                portDISABLE_INTERRUPTS();\r
 \r
+               #if ( configUSE_NEWLIB_REENTRANT == 1 )\r
+               {\r
+                       /* Switch Newlib's _impure_ptr variable to point to the _reent\r
+                       structure specific to the task that will run first. */\r
+                       _impure_ptr = &( pxCurrentTCB->xNewLib_reent );\r
+               }\r
+               #endif /* configUSE_NEWLIB_REENTRANT */\r
+\r
                xSchedulerRunning = pdTRUE;\r
                xTickCount = ( portTickType ) 0U;\r
 \r
@@ -1337,7 +1346,6 @@ signed portBASE_TYPE xTaskResumeAll( void )
 {\r
 tskTCB *pxTCB;\r
 portBASE_TYPE xAlreadyYielded = pdFALSE;\r
-portBASE_TYPE xYieldRequired = pdFALSE;\r
 \r
        /* If uxSchedulerSuspended is zero then this function does not match a\r
        previous call to vTaskSuspendAll(). */\r
@@ -1369,7 +1377,7 @@ portBASE_TYPE xYieldRequired = pdFALSE;
                                        the current task then we should yield. */\r
                                        if( pxTCB->uxPriority >= pxCurrentTCB->uxPriority )\r
                                        {\r
-                                               xYieldRequired = pdTRUE;\r
+                                               xYieldPending = pdTRUE;\r
                                        }\r
                                }\r
 \r
@@ -1382,16 +1390,15 @@ portBASE_TYPE xYieldRequired = pdFALSE;
                                        {\r
                                                if( xTaskIncrementTick() != pdFALSE )\r
                                                {\r
-                                                       xYieldRequired = pdTRUE;\r
+                                                       xYieldPending = pdTRUE;\r
                                                }\r
                                                --uxPendedTicks;\r
                                        }\r
                                }\r
 \r
-                               if( ( xYieldRequired == pdTRUE ) || ( xYieldPending == pdTRUE ) )\r
+                               if( xYieldPending == pdTRUE )\r
                                {\r
                                        xAlreadyYielded = pdTRUE;\r
-                                       xYieldPending = pdFALSE;\r
                                        portYIELD_WITHIN_API();\r
                                }\r
                        }\r
@@ -1519,7 +1526,7 @@ unsigned portBASE_TYPE uxTaskGetNumberOfTasks( void )
                                                        portALT_GET_RUN_TIME_COUNTER_VALUE( ( *pulTotalRunTime ) );\r
                                                #else\r
                                                        *pulTotalRunTime = portGET_RUN_TIME_COUNTER_VALUE();\r
-                                               #endif                                  \r
+                                               #endif\r
                                        }\r
                                }\r
                                #else\r
@@ -1678,6 +1685,17 @@ portBASE_TYPE xSwitchRequired = pdFALSE;
                        }\r
                }\r
                #endif /* ( ( configUSE_PREEMPTION == 1 ) && ( configUSE_TIME_SLICING == 1 ) ) */\r
+               \r
+               #if ( configUSE_TICK_HOOK == 1 )\r
+               {\r
+                       /* Guard against the tick hook being called when the pended tick\r
+                       count is being unwound (when the scheduler is being unlocked). */\r
+                       if( uxPendedTicks == ( unsigned portBASE_TYPE ) 0U )\r
+                       {\r
+                               vApplicationTickHook();\r
+                       }\r
+               }\r
+               #endif /* configUSE_TICK_HOOK */                \r
        }\r
        else\r
        {\r
@@ -1692,16 +1710,14 @@ portBASE_TYPE xSwitchRequired = pdFALSE;
                #endif\r
        }\r
 \r
-       #if ( configUSE_TICK_HOOK == 1 )\r
+       #if ( configUSE_PREEMPTION == 1 )\r
        {\r
-               /* Guard against the tick hook being called when the missed tick\r
-               count is being unwound (when the scheduler is being unlocked). */\r
-               if( uxPendedTicks == ( unsigned portBASE_TYPE ) 0U )\r
+               if( xYieldPending != pdFALSE )\r
                {\r
-                       vApplicationTickHook();\r
+                       xSwitchRequired = pdTRUE;\r
                }\r
        }\r
-       #endif /* configUSE_TICK_HOOK */\r
+       #endif /* configUSE_PREEMPTION */\r
 \r
        return xSwitchRequired;\r
 }\r
@@ -1804,6 +1820,7 @@ void vTaskSwitchContext( void )
        }\r
        else\r
        {\r
+               xYieldPending = pdFALSE;\r
                traceTASK_SWITCHED_OUT();\r
 \r
                #if ( configGENERATE_RUN_TIME_STATS == 1 )\r
@@ -1981,6 +1998,10 @@ portBASE_TYPE xReturn;
                the calling task to know if it should force a context\r
                switch now. */\r
                xReturn = pdTRUE;\r
+\r
+               /* Mark that a yield is pending in case the user is not using the\r
+               "xHigherPriorityTaskWoken" parameter to an ISR safe FreeRTOS function. */\r
+               xYieldPending = pdTRUE;\r
        }\r
        else\r
        {\r
index 0414604f1fa9c3a8b20e8101872f6b3f049cedcd..f9f50b4bd39889cb9fab5e7a5d357b5dcb9b08eb 100644 (file)
@@ -569,6 +569,13 @@ portTickType xTimeNow;
                        case tmrCOMMAND_CHANGE_PERIOD :\r
                                pxTimer->xTimerPeriodInTicks = xMessage.xMessageValue;\r
                                configASSERT( ( pxTimer->xTimerPeriodInTicks > 0 ) );\r
+\r
+                               /* The new period does not really have a reference, and can be\r
+                               longer or shorter than the old one.  The command time is \r
+                               therefore set to the current time, and as the period cannot be\r
+                               zero the next expiry time can only be in the future, meaning\r
+                               (unlike for the xTimerStart() case above) there is no fail case\r
+                               that needs to be handled here. */\r
                                ( void ) prvInsertTimerInActiveList( pxTimer, ( xTimeNow + pxTimer->xTimerPeriodInTicks ), xTimeNow, xTimeNow );\r
                                break;\r
 \r