\r
/* Increment the tick count then switch to the highest priority task\r
that is ready to run. */\r
- vTaskIncrementTick();\r
- vTaskSwitchContext();\r
+ if( xTaskIncrementTick() != pdFALSE )\r
+ {\r
+ vTaskSwitchContext();\r
+ }\r
\r
/* Restore the context of the new task. */\r
portRESTORE_CONTEXT();\r
interrupt (TIMERA0_VECTOR) prvTickISR( void );\r
interrupt (TIMERA0_VECTOR) prvTickISR( void )\r
{\r
- vTaskIncrementTick();\r
+ xTaskIncrementTick();\r
}\r
#endif\r
\r
\r
void vPortSysTickHandler( void * context, alt_u32 id )\r
{\r
- /* Increment the Kernel Tick. */\r
- vTaskIncrementTick();\r
-\r
- /* If using preemption, also force a context switch. */\r
- #if configUSE_PREEMPTION == 1\r
+ /* Increment the kernel tick. */\r
+ if( xTaskIncrementTick() != pdFALSE )\r
+ {\r
vTaskSwitchContext();\r
- #endif\r
-\r
+ }\r
+ \r
/* Clear the interrupt. */\r
IOWR_ALTERA_AVALON_TIMER_STATUS( SYS_CLK_BASE, ~ALTERA_AVALON_TIMER_STATUS_TO_MSK );\r
}\r
\r
.extern pxCurrentTCB\r
.extern vTaskSwitchContext\r
- .extern vTaskIncrementTick\r
+ .extern xTaskIncrementTick\r
.extern vPortISRHandler\r
\r
.global vPortStartFirstTask\r
vPortTickISR:\r
\r
portSAVE_STACK_POINTER_AND_LR\r
- bl vTaskIncrementTick\r
+ bl xTaskIncrementTick\r
\r
#if configUSE_PREEMPTION == 1\r
bl vTaskSwitchContext\r
\r
.extern pxCurrentTCB\r
.extern vTaskSwitchContext\r
- .extern vTaskIncrementTick\r
+ .extern xTaskIncrementTick\r
.extern vPortISRHandler\r
\r
.global vPortStartFirstTask\r
vPortTickISR:\r
\r
portSAVE_STACK_POINTER_AND_LR\r
- bl vTaskIncrementTick\r
+ bl xTaskIncrementTick\r
\r
#if configUSE_PREEMPTION == 1\r
bl vTaskSwitchContext\r
#endif\r
\r
/* These macros allow a critical section to be added around the call to\r
-vTaskIncrementTick(), which is only ever called from interrupts at the kernel\r
+xTaskIncrementTick(), which is only ever called from interrupts at the kernel\r
priority - ie a known priority. Therefore these local macros are a slight\r
optimisation compared to calling the global SET/CLEAR_INTERRUPT_MASK macros,\r
which would require the old IPL to be read first and stored in a local variable. */\r
necessitates. Ensure IPL is at the max syscall value first. */\r
portDISABLE_INTERRUPTS_FROM_KERNEL_ISR();\r
{\r
- vTaskIncrementTick();\r
+ if( xTaskIncrementTick() != pdFALSE )\r
+ {\r
+ taskYIELD();\r
+ }\r
}\r
portENABLE_INTERRUPTS_FROM_KERNEL_ISR();\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
#if configUSE_TICKLESS_IDLE == 1\r
{\r
/* The CPU woke because of a tick. */\r
#define portINITIAL_FPSW ( ( portSTACK_TYPE ) 0x00000100 )\r
\r
/* These macros allow a critical section to be added around the call to\r
-vTaskIncrementTick(), which is only ever called from interrupts at the kernel \r
+xTaskIncrementTick(), which is only ever called from interrupts at the kernel \r
priority - ie a known priority. Therefore these local macros are a slight \r
optimisation compared to calling the global SET/CLEAR_INTERRUPT_MASK macros, \r
which would require the old IPL to be read first and stored in a local variable. */\r
necessitates. Ensure IPL is at the max syscall value first. */\r
portDISABLE_INTERRUPTS_FROM_KERNEL_ISR();\r
{\r
- vTaskIncrementTick(); \r
+ if( TaskIncrementTick() != pdFALSE )\r
+ {\r
+ taskYIELD();\r
+ }\r
}\r
portENABLE_INTERRUPTS_FROM_KERNEL_ISR();\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
{\r
/* Increment the RTOS tick count, then look for the highest priority \r
task that is ready to run. */\r
- vTaskIncrementTick();\r
- \r
- #if configUSE_PREEMPTION == 1\r
+ if( xTaskIncrementTick() != pdFALSE )\r
+ { \r
vTaskSwitchContext();\r
- #endif\r
+ }\r
\r
/* Ready for the next interrupt. */\r
TB_ClearITPendingBit( TB_IT_Update ); \r
unsigned long *pxUpperCSA = NULL;\r
unsigned long xUpperCSA = 0UL;\r
extern volatile unsigned long *pxCurrentTCB;\r
+long lYieldRequired;\r
\r
/* Just to avoid compiler warnings about unused parameters. */\r
( void ) iArg;\r
ulSavedInterruptMask = portSET_INTERRUPT_MASK_FROM_ISR();\r
{\r
/* Increment the Tick. */\r
- vTaskIncrementTick();\r
+ lYieldRequired = xTaskIncrementTick();\r
}\r
portCLEAR_INTERRUPT_MASK_FROM_ISR( ulSavedInterruptMask );\r
\r
- #if configUSE_PREEMPTION == 1\r
+ if( lYieldRequired != pdFALSE )\r
{\r
/* Save the context of a task.\r
The upper context is automatically saved when entering a trap or interrupt.\r
CPU_SRC0.bits.SETR = 0;\r
_isync();\r
}\r
- #endif\r
}\r
/*-----------------------------------------------------------*/\r
\r
; Functions used by scheduler\r
;------------------------------------------------------------------------------\r
EXTERN vTaskSwitchContext\r
- EXTERN vTaskIncrementTick\r
+ EXTERN xTaskIncrementTick\r
\r
; Tick ISR Prototype\r
;------------------------------------------------------------------------------\r
MD_INTTM05:\r
\r
portSAVE_CONTEXT ; Save the context of the current task.\r
- call vTaskIncrementTick ; Call the timer tick function.\r
+ call xTaskIncrementTick ; Call the timer tick function.\r
#if configUSE_PREEMPTION == 1\r
call vTaskSwitchContext ; Call the scheduler to select the next task.\r
#endif\r
{\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
\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
\r
( void ) 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_REG = portNVIC_PENDSVSET_BIT;\r
+ }\r
}\r
portCLEAR_INTERRUPT_MASK_FROM_ISR( 0 );\r
}\r