Quality RTOS & Embedded Software

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


Loading

How thread-safe are *fromISR() functions?

Posted by jeromecwright on March 8, 2017

Some of my team have been questioning how thread safe the *fromISR() functions are.

Currently we use these lightweight API calls in some module interfaces in the case that they are called from high priority interrupts.

They also referenced examples 1 and 2 from the lightweight API section here:

http://www.freertos.org/messagepassingperformance.html#light

Although these examples seem to be legacy code (Version 4.8 ~ ). It does mention "We have done nothing between Listing 1 and Listing 2 to ensure interrupt safety. This is therefore still not appropriate usage if the queue is also accessed from an ISR."

That said, the third example (using the return value to indicate an opportunity to yield) seems to be up to date. And a quick look into the functions save & disable interrupts on entry then restore the register status on exit, which prevents further interrupts. However there is also a critical section in this example placed around the *fromISR() function.

1. Is this third example thread safe? Can it be called from an ISR without the need to create a critical section or manage the thread interactions between queue resources?

I see no reason that the *fromISR() functions cannot be called from tasks as well, just the yield behaviour needs to be managed by the application designer. 2. Is it true that the main difference between the *fromISR() function and the normal API is the control over the yield?

The main reason I would like to do this is for the purpose of re-usability in application code. Having different functions based on whether the queue is being added to from an ISR or a low prio task adds to redundancy, or the need to create wrappers.

Thanks, Jerome.


How thread-safe are *fromISR() functions?

Posted by rtel on March 8, 2017

http://www.freertos.org/messagepassingperformance.html#light

Is that page still linked into the website? Did you find it from a link on a different page?

Whether the 'FromISR' functions are thread safe or not depends on the port you are using. As general rule, if the port supports interrupt nesting then the functions are thread safe because they implement their own critical sections. if the port doesn't support interrupt nesting then the 'FromISR' functions will not have critical sections and will not be thread safe.


How thread-safe are *fromISR() functions?

Posted by jeromecwright on March 15, 2017

I am afraid I don't know if it is still linked to a website. Someone had sent me the link to check over as they had concerns about this. Our port is to SAMD20 ARM Cortex M0+. Which supports nested interrupts.

But all the same it might be wise to protect our fromISR functions with critical sections for portability.

Do you think this might have any undesired behaviour?


How thread-safe are *fromISR() functions?

Posted by rtel on March 15, 2017

The M0 port, unlike the M3, M4 and M7 ports, does not support interrupt nesting. All the other 'M' cores have a basepri reg, but the M0 does not.


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


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

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Renesas

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

Xilinx Microblaze and Zynq partner