FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [February 2009 Threads] Atomic operationsPosted 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.)
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|