Quality RTOS & Embedded Software

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




Loading

Why timer callback function should never attempt to block?

Posted by jvgediya on October 6, 2017

What can be the consequences? Could you please explain with example scenario?

Thanks, Jags


Why timer callback function should never attempt to block?

Posted by rtel on October 6, 2017

All the timer callback functions run in the context of the same timer task. If one of the callback functions blocks, then the timer task is blocked. If a timer should expire while the timer task is blocked then the timer's callback function is not going to run when it should, but whenever the timer task leaves the Blocked state.


Why timer callback function should never attempt to block?

Posted by richard_damon on October 6, 2017

I would say that 'Never' is just slightly too strong a term here (It isn't like blocking in the Idle Hook which will likely crash your system). A timer hook that blocks, or that takes a lot of time to process, can impact all other timer call backs (and functions pended by an ISR), as they all use a common task to run in. It is possible for a user to understand the implications, and carefully do things that might blocks.

An example where blocking in a timer callback would be a system with timer events with tolerances in the 10s of milliseconds, and the timer callback is going to do an I/O operation that might block for 100s of microseconds. That would be very acceptable, It shouldn't do a block that might take a 100 milliseconds though.


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




Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

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

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

OpenRTOS and SafeRTOS