Quality RTOS & Embedded Software

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


Atomic operations

Posted by incrediball on February 26, 2009
A possible idea for future optimizing...

I notice that critical sections are often used for protecting operations, which depending on system architecture may or may not be atomic operations. For example vTaskSuspendAll increments a portBASE_TYPE and xTaskGetTickCount copies a portTickType, both inside of a critical section. On 32 bit ports the critical sections are probably not necessary.

Like the InterlockedIncrement function in Windows, perhaps macros could be defined in a port specific header file that implement simple atomic operations such as increment, decrement, getting and setting variables of varying sizes. The macro can make use of a critical section if the architecture requires it, otherwise it can just do the basic operation. Any operations throughout the program which are currently always protected by critical sections could then use these macros.

(That would also allow the use of some functions such as xTaskGetTickCount inside of interrupts, albeit port dependent, however. I'm often irritated by the restriction that I cannot use xTaskGetTickCount inside of interrupts, but that's another story.)

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

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

Latest News

Meet us at Embedded World. Hall 3A-525.

Hear from Richard Barry at Embedded World. Feb 28, 16:00, Hall 4-428.

Video: Watch James Gosling & Richard Barry at re:Invent, Las Vegas 2017.

FreeRTOS kernel V10.0.1 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