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


Macro to declare Status Reg for Critical Sections

Posted by woody242 on July 24, 2015


We are working on Zync processor and wanted to implement critical sections that could be common between ISRs and App code. The need is due to reuse of some code that used to run on uCOS-II and worked and we prefer not to have two copies one for ISR and one for APP code.

Curious why FreeRTOS does not provide a MACRO to declare a status register variable. For space critical apps this could be empty so no hit on space. We noticed when we pull in the trace code that the trace code provides three macros and is implemented this way for A9 port. IF the critical section macros are implemented properly the trace method would be nice but it must be implemented with critical nesting for it to be guaranteed to work in app code.

Is there any chance a future revision of freeRTOS might provide this macro in any function where critical sections are done to give port developers the flexibility to implement critical nesting and interrupts this way.

We are considering making this change locally but this is obviously not desirable.

Thanks, Woody

Macro to declare Status Reg for Critical Sections

Posted by edwards3 on July 24, 2015

I think on an A9 you can call ulPortSetInterruptMask() and vPortClearInterruptMask() from tasks and interrupts. vPortClearInterruptMask() takes the value returned by ulPortSetInterruptMask() as its parameter.

Macro to declare Status Reg for Critical Sections

Posted by rtel on July 26, 2015

"in the beginning" FreeRTOS was only used on really tiny processors and didn't support interrupt nesting so the critical nesting method was chosen to be simple and use no stack (back then stack was the limiting factor). Later ports ports were to larger parts, and interrupt nesting was supported, so the interrupt safe method was introduced - but only for ports that support interrupt nesting.

Somewhere, in the forum, or on a ticket in SourceForge, there is an implementation provided by somebody that allows both methods to be replaced by a single method while maintaining backward compatibility. It uses macros and block scope variables though, which is technically against the coding standard (block scope variables), but it would be nice to incorporate something like it into the code.

Macro to declare Status Reg for Critical Sections

Posted by woody242 on July 27, 2015

Thanks, I'll take a look. Seems like the coding standard violation could be avoided if a macro to declare a function scope variable was added. Do you think this might be considered in a future release?

Macro to declare Status Reg for Critical Sections

Posted by rtel on July 27, 2015

All ideas are considered...


[ 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