Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




Loading

What if a tick gets pended after xExpectedIdleTime is calculated?

Posted by caseymillsdavis on September 21, 2015

In the GCC/ARM_CM3 implementation of vPortSuppressTicksAndSleep, a SysTick interrupt could fire and pend a tick after the scheduler is suspended and before the SysTick has been stopped. ulReloadValue would then get calculated using the SysTick current-value-register that has just been refreshed and a value of xExpectedIdleTime that doesn't account for this recent tick. I think the result would be a SysTick wake-up scheduled a tick too late.

Is this reasoning correct?


What if a tick gets pended after xExpectedIdleTime is calculated?

Posted by rtel on September 21, 2015

This could conceivable happen if the Idle task started to run right at the end of a time slice (immediately before a tick interrupt).

I'm not sure the scenario you highlight adds any additional uncertainty than say, calling vTaskDelay( 1 ). A time measured in ticks is only accurate to the resolution of one tick period, so vTaskDelay( 1 ) could block for 0.001 of a tick period, or 0.999 of a tick period, depending on how far through the time clice it was called. However, unlike a pure vTaskDelay( 1 ), it could result in some time slippage - but that is noted in the code comments.

Anything that stops the timer will inevitably result in some time slippage forward or backwards (depending on the compensation value). The scenario you highlight could be mitigated by updating eTaskConfirmSleepModeStatus() so it returns eAbortSleep if a tick is pending (it already aborts if the tick attempted a context switch), but then you are more likely to abort a sleep, which in turn means you will be turning the clock off more often (when re-trying an aborted sleep) so I'm not sure you gain anythng.

Other than some clock slippage (relative to calendar time) - do you see anything actually dangerious in the implementation. By that I mean, somethign that could cause a crash, or lock up, etc.?

Regards.


What if a tick gets pended after xExpectedIdleTime is calculated?

Posted by caseymillsdavis on September 21, 2015

What if a tick gets pended after xExpectedIdleTime is calculated?

Posted by caseymillsdavis on September 21, 2015

Thanks for the fast reply.

Your example from "vTaskDelay( 1)" clarifies things and I think you are right that this scenario does not add any more uncertainty than that. I didn't see any other concern apart from clock slippage.


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists