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

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 ]    [ 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