]> git.sur5r.net Git - freertos/commitdiff
Convert some ports to use xTaskIncrementTick() in place of vTaskIncrementTick().
authorrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Thu, 6 Jun 2013 15:46:40 +0000 (15:46 +0000)
committerrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Thu, 6 Jun 2013 15:46:40 +0000 (15:46 +0000)
Move DSB instructions to before WFI instructions in line with ARM recommendations.

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

27 files changed:
FreeRTOS/Source/portable/BCC/16BitDOS/Flsh186/port.c
FreeRTOS/Source/portable/BCC/16BitDOS/PC/port.c
FreeRTOS/Source/portable/CCS/MSP430X/portext.asm
FreeRTOS/Source/portable/CodeWarrior/ColdFire_V1/port.c
FreeRTOS/Source/portable/CodeWarrior/HCS12/port.c
FreeRTOS/Source/portable/GCC/ARM7_AT91FR40008/portISR.c
FreeRTOS/Source/portable/GCC/ARM7_AT91SAM7S/portISR.c
FreeRTOS/Source/portable/GCC/ARM7_LPC2000/portISR.c
FreeRTOS/Source/portable/GCC/ARM7_LPC23xx/portISR.c
FreeRTOS/Source/portable/GCC/ARM_CM0/port.c
FreeRTOS/Source/portable/GCC/ARM_CM3/port.c
FreeRTOS/Source/portable/GCC/ARM_CM3_MPU/port.c
FreeRTOS/Source/portable/GCC/ARM_CM4F/port.c
FreeRTOS/Source/portable/GCC/ATMega323/port.c
FreeRTOS/Source/portable/GCC/AVR32_UC3/port.c
FreeRTOS/Source/portable/GCC/CORTUS_APS3/port.c
FreeRTOS/Source/portable/GCC/H8S2329/port.c
FreeRTOS/Source/portable/GCC/HCS12/port.c
FreeRTOS/Source/portable/GCC/MCF5235/port.c
FreeRTOS/Source/portable/GCC/MicroBlaze/port.c
FreeRTOS/Source/portable/GCC/MicroBlazeV8/port.c
FreeRTOS/Source/portable/IAR/ARM_CM3/port.c
FreeRTOS/Source/portable/IAR/ARM_CM4F/port.c
FreeRTOS/Source/portable/IAR/RX600/port.c
FreeRTOS/Source/portable/MSVC-MingW/port.c
FreeRTOS/Source/portable/RVDS/ARM_CM3/port.c
FreeRTOS/Source/portable/RVDS/ARM_CM4F/port.c

index 52b9bdeb40dc640d063a8063ae7895732235758a..6d7effbfcf762eb360ae27bb56c19fe06857cc67 100644 (file)
@@ -195,10 +195,11 @@ is being used. */
        static void __interrupt __far prvPreemptiveTick( void )\r
        {\r
                /* Get the scheduler to update the task states following the tick. */\r
-               vTaskIncrementTick();\r
-\r
-               /* Switch in the context of the next task to be run. */\r
-               portSWITCH_CONTEXT();\r
+               if( xTaskIncrementTick() != pdFALSE )\r
+               {\r
+                       /* Switch in the context of the next task to be run. */\r
+                       portSWITCH_CONTEXT();\r
+               }\r
 \r
                /* Reset the PIC ready for the next time. */\r
                portRESET_PIC();\r
@@ -208,7 +209,7 @@ is being used. */
        {\r
                /* Same as preemptive tick, but the cooperative scheduler is being used\r
                so we don't have to switch in the context of the next task. */\r
-               vTaskIncrementTick();\r
+               xTaskIncrementTick();\r
                portRESET_PIC();\r
        }\r
 #endif\r
index a5874f999759e40225228485f847884594b2d487..4e9f8650f4ba223ba6323f927900bbfe4800198b 100644 (file)
@@ -216,10 +216,11 @@ scheduler is being used. */
        static void __interrupt __far prvPreemptiveTick( void )\r
        {\r
                /* Get the scheduler to update the task states following the tick. */\r
-               vTaskIncrementTick();\r
-\r
-               /* Switch in the context of the next task to be run. */\r
-               portSWITCH_CONTEXT();\r
+               if( xTaskIncrementTick() != pdFALSE )\r
+               {\r
+                       /* Switch in the context of the next task to be run. */\r
+                       portSWITCH_CONTEXT();\r
+               }\r
 \r
                /* Reset the PIC ready for the next time. */\r
                prvPortResetPIC();\r
@@ -229,7 +230,7 @@ scheduler is being used. */
        {\r
                /* Same as preemptive tick, but the cooperative scheduler is being used\r
                so we don't have to switch in the context of the next task. */\r
-               vTaskIncrementTick();\r
+               xTaskIncrementTick();\r
                prvPortResetPIC();\r
        }\r
 #endif\r
index 8e89f9b67844ef3aa8ea8fe0d57befd22ff30466..1d5d79e1d40a71a2aaa42e657efa5d36ae1ebe4c 100644 (file)
@@ -57,7 +57,7 @@
 \r
        .include data_model.h\r
 \r
-       .global vTaskIncrementTick\r
+       .global xTaskIncrementTick\r
        .global vTaskSwitchContext\r
        .global vPortSetupTimerInterrupt\r
        .global pxCurrentTCB\r
@@ -112,7 +112,7 @@ vPortPreemptiveTickISR: .asmfunc
        push.w sr\r
        portSAVE_CONTEXT\r
                                \r
-       call_x  #vTaskIncrementTick\r
+       call_x  #xTaskIncrementTick\r
        call_x  #vTaskSwitchContext\r
                \r
        portRESTORE_CONTEXT\r
@@ -128,7 +128,7 @@ vPortCooperativeTickISR: .asmfunc
        push.w sr\r
        portSAVE_CONTEXT\r
                                \r
-       call_x  #vTaskIncrementTick\r
+       call_x  #xTaskIncrementTick\r
                \r
        portRESTORE_CONTEXT\r
        \r
index 2f4ae0fd6bcbaebe19df67fff55861d40370e23f..b048b53e8d6dfa52ee72ef986e7b5cbc4cb7e232 100644 (file)
@@ -220,16 +220,11 @@ unsigned long ulSavedInterruptMask;
        /* Increment the RTOS tick. */\r
        ulSavedInterruptMask = portSET_INTERRUPT_MASK_FROM_ISR();\r
        {\r
-               vTaskIncrementTick();\r
+               if( xTaskIncrementTick() != pdFALSE )\r
+               {\r
+                       taskYIELD();\r
+               }\r
        }\r
        portCLEAR_INTERRUPT_MASK_FROM_ISR( ulSavedInterruptMask );\r
-\r
-       /* If we are using the pre-emptive scheduler then also request a\r
-       context switch as incrementing the tick could have unblocked a task. */\r
-       #if configUSE_PREEMPTION == 1\r
-       {\r
-               taskYIELD();\r
-       }\r
-       #endif\r
 }\r
 \r
index e1bbe7ae7d8946b09a23f2cefa14c2ce018472ee..5dd8a8ec04105407c712e1847c7e665ae0a27093 100644 (file)
@@ -260,11 +260,10 @@ void interrupt vPortTickInterrupt( void )
                portSAVE_CONTEXT();\r
 \r
                /* Increment the tick ... */\r
-               vTaskIncrementTick();\r
-\r
-               /* ... then see if the new tick value has necessitated a\r
-               context switch. */\r
-               vTaskSwitchContext();\r
+               if( xTaskIncrementTick() != pdFALSE )\r
+               {\r
+                       vTaskSwitchContext();\r
+               }\r
 \r
                TFLG1 = 1;                                                                 \r
 \r
@@ -274,7 +273,7 @@ void interrupt vPortTickInterrupt( void )
        }\r
        #else\r
        {\r
-               vTaskIncrementTick();\r
+               xTaskIncrementTick();\r
                TFLG1 = 1;\r
        }\r
        #endif\r
index 60a0d214ac7fd8b9ae6cadf14f96ea20dc5319cb..ef503e61c7facf4d3a145cb7ef43e7c737756a3c 100644 (file)
@@ -161,7 +161,7 @@ void vPortYieldProcessor( void )
                /* Clear tick timer interrupt indication. */\r
                ulDummy = portTIMER_REG_BASE_PTR->TC_SR;  \r
 \r
-               vTaskIncrementTick();\r
+               xTaskIncrementTick();\r
 \r
                /* Acknowledge the interrupt at AIC level... */\r
                AT91C_BASE_AIC->AIC_EOICR = portCLEAR_AIC_INTERRUPT;\r
@@ -186,8 +186,10 @@ void vPortYieldProcessor( void )
 \r
                /* Increment the RTOS tick count, then look for the highest priority \r
                task that is ready to run. */\r
-               vTaskIncrementTick();\r
-               vTaskSwitchContext();\r
+               if( xTaskIncrementTick() != pdFALSE )\r
+               {\r
+                       vTaskSwitchContext();\r
+               }\r
 \r
                /* Acknowledge the interrupt at AIC level... */\r
                AT91C_BASE_AIC->AIC_EOICR = portCLEAR_AIC_INTERRUPT;\r
index ac40e1dedd0f6c93e373d50ee8f94936e3098dac..7eed8348cee3a8fa649b0424bb66de4dab965f18 100644 (file)
@@ -163,7 +163,7 @@ void vPortYieldProcessor( void )
                /* Increment the tick count - which may wake some tasks but as the\r
                preemptive scheduler is not being used any woken task is not given\r
                processor time no matter what its priority. */\r
-               vTaskIncrementTick();\r
+               xTaskIncrementTick();\r
                \r
                /* Clear the PIT interrupt. */\r
                ulDummy = AT91C_BASE_PITC->PITC_PIVR;\r
@@ -183,10 +183,11 @@ void vPortYieldProcessor( void )
                portSAVE_CONTEXT();                     \r
 \r
                /* Increment the tick count - this may wake a task. */\r
-               vTaskIncrementTick();\r
-\r
-               /* Find the highest priority task that is ready to run. */\r
-               vTaskSwitchContext();\r
+               if( xTaskIncrementTick() != pdFALSE )\r
+               {\r
+                       /* Find the highest priority task that is ready to run. */\r
+                       vTaskSwitchContext();\r
+               }\r
                \r
                /* End the interrupt in the AIC. */\r
                AT91C_BASE_AIC->AIC_EOICR = AT91C_BASE_PITC->PITC_PIVR;;\r
index f4b15b1761e9f7f4330a1aef8681c8cc6018c7db..02dbf8eee9e51c5d998fa5de8f1e951fcd907775 100644 (file)
@@ -166,7 +166,7 @@ void vTickISR( void )
 \r
        /* Increment the RTOS tick count, then look for the highest priority \r
        task that is ready to run. */\r
-       __asm volatile( "bl vTaskIncrementTick" );\r
+       __asm volatile( "bl xTaskIncrementTick" );\r
 \r
        #if configUSE_PREEMPTION == 1\r
                __asm volatile( "bl vTaskSwitchContext" );\r
index 3f89bd5c53ff993682d06c2a19e4cd574cd3f6a4..e39026f1ca63bf8d3f11a83248f9809ddc4bdd6d 100644 (file)
@@ -150,7 +150,7 @@ void vPortYieldProcessor( void )
        void vNonPreemptiveTick( void ) __attribute__ ((interrupt ("IRQ")));\r
        void vNonPreemptiveTick( void )\r
        {       \r
-               vTaskIncrementTick();\r
+               xTaskIncrementTick();\r
                T0IR = 2;\r
                VICVectAddr = portCLEAR_VIC_INTERRUPT;\r
        }\r
@@ -167,7 +167,7 @@ void vPortYieldProcessor( void )
 \r
                /* Increment the RTOS tick count, then look for the highest priority \r
                task that is ready to run. */\r
-               __asm volatile( "bl vTaskIncrementTick" );\r
+               __asm volatile( "bl xTaskIncrementTick" );\r
                __asm volatile( "bl vTaskSwitchContext" );\r
 \r
                /* Ready for the next interrupt. */\r
index 6b8a8a84f94de827afc6eda9bc8844799891e110..d0540db2ff45910aa209846d076b82ac1b8d3599 100644 (file)
@@ -293,14 +293,14 @@ void xPortSysTickHandler( void )
 {\r
 unsigned long ulDummy;\r
 \r
-       /* If using preemption, also force a context switch. */\r
-       #if configUSE_PREEMPTION == 1\r
-               *(portNVIC_INT_CTRL) = portNVIC_PENDSVSET;\r
-       #endif\r
-\r
        ulDummy = portSET_INTERRUPT_MASK_FROM_ISR();\r
        {\r
-               vTaskIncrementTick();\r
+               /* Increment the RTOS tick. */\r
+               if( xTaskIncrementTick() != pdFALSE )\r
+               {\r
+                       /* Pend a context switch. */\r
+                       *(portNVIC_INT_CTRL) = portNVIC_PENDSVSET;\r
+               }\r
        }\r
        portCLEAR_INTERRUPT_MASK_FROM_ISR( ulDummy );\r
 }\r
index a0bfe1d39ca20f58050696de77e42145214174e9..8acc0a53f99869e0d55a8c19dfe106ef94f56ee8 100644 (file)
@@ -354,11 +354,6 @@ void xPortPendSVHandler( void )
 \r
 void xPortSysTickHandler( void )\r
 {\r
-       /* If using preemption, also force a context switch. */\r
-       #if configUSE_PREEMPTION == 1\r
-               portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT;\r
-       #endif\r
-\r
        /* Only reset the systick load register if configUSE_TICKLESS_IDLE is set to\r
        1.  If it is set to 0 tickless idle is not being used.  If it is set to a\r
        value other than 0 or 1 then a timer other than the SysTick is being used\r
@@ -367,9 +362,18 @@ void xPortSysTickHandler( void )
                portNVIC_SYSTICK_LOAD_REG = ulTimerReloadValueForOneTick;\r
        #endif\r
 \r
+       /* The SysTick runs at the lowest interrupt priority, so when this interrupt\r
+       executes all interrupts must be unmasked.  There is therefore no need to\r
+       save and then restore the interrupt mask value as its value is already\r
+       known. */\r
        ( void ) portSET_INTERRUPT_MASK_FROM_ISR();\r
        {\r
-               vTaskIncrementTick();\r
+               if( xTaskIncrementTick() != pdFALSE )\r
+               {\r
+                       /* A context switch is required.  Context switching is performed in\r
+                       the PendSV interrupt.  Pend the PendSV interrupt. */\r
+                       portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT;\r
+               }\r
        }\r
        portCLEAR_INTERRUPT_MASK_FROM_ISR( 0 );\r
 }\r
@@ -444,8 +448,8 @@ void xPortSysTickHandler( void )
                        configPRE_SLEEP_PROCESSING( xModifiableIdleTime );\r
                        if( xModifiableIdleTime > 0 )\r
                        {\r
-                               __asm volatile( "wfi" );\r
                                __asm volatile( "dsb" );\r
+                               __asm volatile( "wfi" );\r
                                __asm volatile( "isb" );\r
                        }\r
                        configPOST_SLEEP_PROCESSING( xExpectedIdleTime );\r
index 4d4870136c146465f6014fbe076848f06fa8c94f..ffc58598aceb4fbc32d30da44ac58f58739a085b 100644 (file)
@@ -452,14 +452,14 @@ void xPortSysTickHandler( void )
 {\r
 unsigned long ulDummy;\r
 \r
-       /* If using preemption, also force a context switch. */\r
-       #if configUSE_PREEMPTION == 1\r
-               *(portNVIC_INT_CTRL) = portNVIC_PENDSVSET;\r
-       #endif\r
-\r
        ulDummy = portSET_INTERRUPT_MASK_FROM_ISR();\r
        {\r
-               vTaskIncrementTick();\r
+               /* Increment the RTOS tick. */\r
+               if( xTaskIncrementTick() != pdFALSE )\r
+               {\r
+                       /* Pend a context switch. */\r
+                       *(portNVIC_INT_CTRL) = portNVIC_PENDSVSET;\r
+               }\r
        }\r
        portCLEAR_INTERRUPT_MASK_FROM_ISR( ulDummy );\r
 }\r
index 56ec249bb9179d75aed65ea2b6e420d9f71dbea2..23e194bbe11f1b7488f7280a4f6abf1ffd0a0b8d 100644 (file)
@@ -387,11 +387,6 @@ void xPortPendSVHandler( void )
 \r
 void xPortSysTickHandler( void )\r
 {\r
-       /* If using preemption, also force a context switch. */\r
-       #if configUSE_PREEMPTION == 1\r
-               portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT;\r
-       #endif\r
-\r
        /* Only reset the systick load register if configUSE_TICKLESS_IDLE is set to\r
        1.  If it is set to 0 tickless idle is not being used.  If it is set to a\r
        value other than 0 or 1 then a timer other than the SysTick is being used\r
@@ -402,7 +397,12 @@ void xPortSysTickHandler( void )
 \r
        ( void ) portSET_INTERRUPT_MASK_FROM_ISR();\r
        {\r
-               vTaskIncrementTick();\r
+               /* Increment the RTOS tick count. */\r
+               if( xTaskIncrementTick() != pdFALSE )\r
+               {\r
+                       /* Pend a context switch. */\r
+                       portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT;\r
+               }\r
        }\r
        portCLEAR_INTERRUPT_MASK_FROM_ISR( 0 );\r
 }\r
@@ -477,8 +477,8 @@ void xPortSysTickHandler( void )
                        configPRE_SLEEP_PROCESSING( xModifiableIdleTime );\r
                        if( xModifiableIdleTime > 0 )\r
                        {\r
-                               __asm volatile( "wfi" );\r
                                __asm volatile( "dsb" );\r
+                               __asm volatile( "wfi" );\r
                                __asm volatile( "isb" );\r
                        }\r
                        configPOST_SLEEP_PROCESSING( xExpectedIdleTime );\r
index d53607a67db2829209352bbc928f310bc5b61568..29f40d4c202f5502846081c4acbfad2453c612b8 100644 (file)
@@ -393,8 +393,10 @@ void vPortYieldFromTick( void ) __attribute__ ( ( naked ) );
 void vPortYieldFromTick( void )\r
 {\r
        portSAVE_CONTEXT();\r
-       vTaskIncrementTick();\r
-       vTaskSwitchContext();\r
+       if( xTaskIncrementTick() != pdFALSE )\r
+       {\r
+               vTaskSwitchContext();\r
+       }\r
        portRESTORE_CONTEXT();\r
 \r
        asm volatile ( "ret" );\r
@@ -463,7 +465,7 @@ unsigned char ucHighByte, ucLowByte;
        void SIG_OUTPUT_COMPARE1A( void ) __attribute__ ( ( signal ) );\r
        void SIG_OUTPUT_COMPARE1A( void )\r
        {\r
-               vTaskIncrementTick();\r
+               xTaskIncrementTick();\r
        }\r
 #endif\r
 \r
index 691b71201863446f24f3a010ac97f89f88fb8a7e..43cbc4b4c1af6b6e9828ea768858821e709865c4 100644 (file)
@@ -254,7 +254,7 @@ __attribute__((__naked__)) static void vTick( void )
        /* Because FreeRTOS is not supposed to run with nested interrupts, put all OS\r
        calls in a critical section . */\r
        portENTER_CRITICAL();\r
-               vTaskIncrementTick();\r
+               xTaskIncrementTick();\r
        portEXIT_CRITICAL();\r
 \r
        /* Restore the context of the "elected task". */\r
index 9e5b31564e6dfdebf62e3abd19ebc3c8367d2bc0..bfed6932f79052552dce64112a26521d1569b06d 100644 (file)
@@ -170,12 +170,11 @@ void interrupt31_handler( void )
 static void prvProcessTick( void ) __attribute__((noinline));\r
 static void prvProcessTick( void )\r
 {\r
-       vTaskIncrementTick();\r
-\r
-       #if configUSE_PREEMPTION == 1\r
+       if( xTaskIncrementTick() != pdFALSE )\r
+       {\r
                vTaskSwitchContext();\r
-       #endif\r
-\r
+       }\r
+               \r
        /* Clear the Tick Interrupt. */\r
        counter1->expired = 0;\r
 }\r
index ce1e53abc0da5253d2801861e7a2a80d099226f7..d304992317fc8ea24f11bc824d0b05f050b19979 100644 (file)
@@ -293,8 +293,10 @@ void vPortYield( void )
        {\r
                portSAVE_STACK_POINTER();\r
                \r
-               vTaskIncrementTick();\r
-               vTaskSwitchContext();\r
+               if( xTaskIncrementTick() != pdFALSE )\r
+               {\r
+                       vTaskSwitchContext();\r
+               }\r
 \r
                /* Clear the interrupt. */\r
                TSR1 &= ~0x01;\r
@@ -312,7 +314,7 @@ void vPortYield( void )
        void vTickISR( void ) __attribute__ ( ( interrupt_handler ) );\r
        void vTickISR( void )\r
        {\r
-               vTaskIncrementTick();\r
+               xTaskIncrementTick();\r
 \r
                /* Clear the interrupt. */\r
                TSR1 &= ~0x01;\r
index 8835eb118a76a1349594faad45bdbd628a7d98b2..c551de1bfeac63d0c6167c74aef7f80d18cbfbf8 100644 (file)
@@ -263,11 +263,11 @@ void vPortTickInterrupt( void )
                portSAVE_CONTEXT();\r
 \r
                /* Increment the tick ... */\r
-               vTaskIncrementTick();\r
-\r
-               /* ... then see if the new tick value has necessitated a\r
-               context switch. */\r
-               vTaskSwitchContext();\r
+               if( xTaskIncrementTick() != pdFALSE )\r
+               {\r
+                       /* A context switch is necessary. */\r
+                       vTaskSwitchContext();\r
+               }\r
 \r
                /* Restore the context of a task - which may be a different task\r
                to that interrupted. */\r
@@ -275,7 +275,7 @@ void vPortTickInterrupt( void )
        }\r
        #else\r
        {\r
-               vTaskIncrementTick();\r
+               xTaskIncrementTick();\r
        }\r
        #endif\r
 \r
index 837ad44bb2246169ea327d68d085f433d045f9da..f5b6e4f68e052d5f8cec3dabdf687b5282b3a13b 100644 (file)
@@ -194,7 +194,7 @@ prvPortPreemptiveTick ( void )
      * simply increment the system tick.\r
      */\r
 \r
-    vTaskIncrementTick(  );\r
+    xTaskIncrementTick();\r
     MCF_PIT_PCSR0 |= MCF_PIT_PCSR_PIF;\r
 }\r
 \r
@@ -209,8 +209,10 @@ prvPortPreemptiveTick( void )
 #endif\r
     portSAVE_CONTEXT(  );\r
     MCF_PIT_PCSR0 |= MCF_PIT_PCSR_PIF;\r
-    vTaskIncrementTick(  );\r
-    vTaskSwitchContext(  );\r
+    if( xTaskIncrementTick() != pdFALSE )\r
+       {\r
+               vTaskSwitchContext(  );\r
+       }\r
     portRESTORE_CONTEXT(  );\r
 }\r
 #endif\r
index d2c5529059a9bc14ae7e66babe67934164dae8ad..4d796f741d1dfeec5847552915854d7f25d01d8d 100644 (file)
@@ -359,17 +359,14 @@ void vTickISR( void *pvBaseAddress )
 unsigned long ulCSR;\r
 \r
        /* Increment the RTOS tick - this might cause a task to unblock. */\r
-       vTaskIncrementTick();\r
+       if( xTaskIncrementTick() != pdFALSE )\r
+       {\r
+               vTaskSwitchContext();\r
+       }\r
 \r
        /* Clear the timer interrupt */\r
        ulCSR = XTmrCtr_mGetControlStatusReg(XPAR_OPB_TIMER_1_BASEADDR, 0);     \r
        XTmrCtr_mSetControlStatusReg( XPAR_OPB_TIMER_1_BASEADDR, portCOUNTER_0, ulCSR );\r
-\r
-       /* If we are using the preemptive scheduler then we also need to determine\r
-       if this tick should cause a context switch. */\r
-       #if configUSE_PREEMPTION == 1\r
-               vTaskSwitchContext();\r
-       #endif\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
index f3f5a95a066804897f8c1db9888fcaa419956c6d..d85a428fc31398d0830936ff4b897cc45ed1a6bc 100644 (file)
@@ -433,15 +433,11 @@ extern void vApplicationClearTimerInterrupt( void );
        vApplicationClearTimerInterrupt();\r
 \r
        /* Increment the RTOS tick - this might cause a task to unblock. */\r
-       vTaskIncrementTick();\r
-\r
-       /* If the preemptive scheduler is being used then a context switch should be\r
-       requested in case incrementing the tick unblocked a task, or a time slice\r
-       should cause another task to enter the Running state. */\r
-       #if configUSE_PREEMPTION == 1\r
+       if( xTaskIncrementTick() != pdFALSE )\r
+       {\r
                /* Force vTaskSwitchContext() to be called as the interrupt exits. */\r
                ulTaskSwitchRequested = 1;\r
-       #endif\r
+       }\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
index c8104c6bee0ba2aaca960dc32949e6c89def4323..d2ea44745b5737e630390489e382edd8a240e182 100644 (file)
@@ -250,11 +250,6 @@ void vPortExitCritical( void )
 \r
 void xPortSysTickHandler( void )\r
 {\r
-       /* If using preemption, also force a context switch. */\r
-       #if configUSE_PREEMPTION == 1\r
-               portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT;\r
-       #endif\r
-\r
        /* Only reset the systick load register if configUSE_TICKLESS_IDLE is set to\r
        1.  If it is set to 0 tickless idle is not being used.  If it is set to a\r
        value other than 0 or 1 then a timer other than the SysTick is being used\r
@@ -265,7 +260,10 @@ void xPortSysTickHandler( void )
 \r
        ( void ) portSET_INTERRUPT_MASK_FROM_ISR();\r
        {\r
-               vTaskIncrementTick();\r
+               if( xTaskIncrementTick() != pdFALSE )\r
+               {\r
+                       portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT;\r
+               }\r
        }\r
        portCLEAR_INTERRUPT_MASK_FROM_ISR( 0 );\r
 }\r
@@ -340,8 +338,8 @@ void xPortSysTickHandler( void )
                        configPRE_SLEEP_PROCESSING( xModifiableIdleTime );\r
                        if( xModifiableIdleTime > 0 )\r
                        {\r
-                               __WFI();\r
                                __DSB();\r
+                               __WFI();\r
                                __ISB();\r
                        }\r
                        configPOST_SLEEP_PROCESSING( xExpectedIdleTime );\r
index 3d55afae49b7bafdeb3e25fc61d70d150b78c0c7..a9264f3fcf86bb70f00bbe329a3e8319dc1665d8 100644 (file)
@@ -365,8 +365,8 @@ void xPortSysTickHandler( void )
                        configPRE_SLEEP_PROCESSING( xModifiableIdleTime );\r
                        if( xModifiableIdleTime > 0 )\r
                        {\r
-                               __WFI();\r
                                __DSB();\r
+                               __WFI();\r
                                __ISB();\r
                        }\r
                        configPOST_SLEEP_PROCESSING( xExpectedIdleTime );\r
index 86bfbd43690aababb157b5801f980603d3c25709..0306bb7de4946e5f61a8718f4350b79aeb12b8f6 100644 (file)
     ***************************************************************************\r
 \r
 \r
-    http://www.FreeRTOS.org - Documentation, books, training, latest versions, \r
+    http://www.FreeRTOS.org - Documentation, books, training, latest versions,\r
     license and Real Time Engineers Ltd. contact details.\r
 \r
     http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
     including FreeRTOS+Trace - an indispensable productivity tool, and our new\r
     fully thread aware and reentrant UDP/IP stack.\r
 \r
-    http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High \r
-    Integrity Systems, who sell the code with commercial support, \r
+    http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High\r
+    Integrity Systems, who sell the code with commercial support,\r
     indemnification and middleware, under the OpenRTOS brand.\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
+\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
 \r
@@ -119,13 +119,13 @@ extern void *pxCurrentTCB;
 portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE pxCode, void *pvParameters )\r
 {\r
        /* R0 is not included as it is the stack pointer. */\r
-       \r
+\r
        *pxTopOfStack = 0x00;\r
        pxTopOfStack--;\r
        *pxTopOfStack = portINITIAL_PSW;\r
        pxTopOfStack--;\r
        *pxTopOfStack = ( portSTACK_TYPE ) pxCode;\r
-       \r
+\r
        /* When debugging it can be useful if every register is set to a known\r
        value.  Otherwise code space can be saved by just setting the registers\r
        that need to be set. */\r
@@ -166,9 +166,9 @@ portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE
                pxTopOfStack -= 15;\r
        }\r
        #endif\r
-       \r
+\r
        *pxTopOfStack = ( portSTACK_TYPE ) pvParameters; /* R1 */\r
-       pxTopOfStack--;                         \r
+       pxTopOfStack--;\r
        *pxTopOfStack = portINITIAL_FPSW;\r
        pxTopOfStack--;\r
        *pxTopOfStack = 0x12345678; /* Accumulator. */\r
@@ -191,12 +191,12 @@ extern void vApplicationSetupTimerInterrupt( void );
                use.  A demo application is provided to show a suitable example. */\r
                vApplicationSetupTimerInterrupt();\r
 \r
-               /* Enable the software interrupt. */            \r
+               /* Enable the software interrupt. */\r
                _IEN( _ICU_SWINT ) = 1;\r
-               \r
+\r
                /* Ensure the software interrupt is clear. */\r
                _IR( _ICU_SWINT ) = 0;\r
-               \r
+\r
                /* Ensure the software interrupt is set to the kernel priority. */\r
                _IPR( _ICU_SWINT ) = configKERNEL_INTERRUPT_PRIORITY;\r
 \r
@@ -214,19 +214,17 @@ __interrupt void vTickISR( void )
 {\r
        /* Re-enable interrupts. */\r
        __enable_interrupt();\r
-       \r
+\r
        /* Increment the tick, and perform any processing the new tick value\r
        necessitates. */\r
        __set_interrupt_level( configMAX_SYSCALL_INTERRUPT_PRIORITY );\r
        {\r
-               vTaskIncrementTick();\r
+               if( xTaskIncrementTick() != pdFALSE )\r
+               {\r
+                       taskYIELD();\r
+               }\r
        }\r
        __set_interrupt_level( configKERNEL_INTERRUPT_PRIORITY );\r
-       \r
-       /* Only select a new task if the preemptive scheduler is being used. */\r
-       #if( configUSE_PREEMPTION == 1 )\r
-               taskYIELD();\r
-       #endif\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
index 8b82a8c9679f78f17b6c6fea520469c7f0103683..a19858de506ddd34e1f246537ca212fd303b7c97 100644 (file)
@@ -301,18 +301,7 @@ static unsigned long prvProcessTickInterrupt( void )
 unsigned long ulSwitchRequired;\r
 \r
        /* Process the tick itself. */\r
-       vTaskIncrementTick();\r
-       #if( configUSE_PREEMPTION != 0 )\r
-       {\r
-               /* A context switch is only automatically performed from the tick\r
-               interrupt if the pre-emptive scheduler is being used. */\r
-               ulSwitchRequired = pdTRUE;\r
-       }\r
-       #else\r
-       {\r
-               ulSwitchRequired = pdFALSE;\r
-       }\r
-       #endif\r
+       ulSwitchRequired = ( unsigned long ) xTaskIncrementTick();\r
 \r
        return ulSwitchRequired;\r
 }\r
index f1a982acabc632a55ad2802a4fe0152f5b4c7d68..c721f1fe35b27f0d55818987719b8e9b09580565 100644 (file)
@@ -417,8 +417,8 @@ void xPortSysTickHandler( void )
                        configPRE_SLEEP_PROCESSING( xModifiableIdleTime );\r
                        if( xModifiableIdleTime > 0 )\r
                        {\r
-                               __wfi();\r
                                __dsb( portSY_FULL_READ_WRITE );\r
+                               __wfi();\r
                                __isb( portSY_FULL_READ_WRITE );\r
                        }\r
                        configPOST_SLEEP_PROCESSING( xExpectedIdleTime );\r
index d935dedfc152ddc9b9fe2cf62bc75b0a5b2400d3..345f386bfc2335c188d1dbd34fd3f56ed9d91423 100644 (file)
@@ -480,8 +480,8 @@ void xPortSysTickHandler( void )
                        configPRE_SLEEP_PROCESSING( xModifiableIdleTime );\r
                        if( xModifiableIdleTime > 0 )\r
                        {\r
-                               __wfi();\r
                                __dsb( portSY_FULL_READ_WRITE );\r
+                               __wfi();\r
                                __isb( portSY_FULL_READ_WRITE );\r
                        }\r
                        configPOST_SLEEP_PROCESSING( xExpectedIdleTime );\r