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.)
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.