-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Minimize the use of the taskENTER_CRITICAL and taskEXIT_CRITICAL #1059
Comments
@n9wxu
I'm not an expert in FreeRTOS, but I can help with this simple task. I modified this files The tests make in AVR architectures (that is 8bits) looks like OK. example the compile in AVRATMega_323_WinAVR
I really think that I need execute more specific test. |
@n9wxu Then, I think that the BaseType_t when the OS is running in 8bit cpu , if BaseType_t is bigger than 8 bit (like type int, usually 16 bits), we don't access this is atomic context because this types is don't atomic in this CPUs. But, that said, I'm unable to think why this change (remove task{ENTER|EXIT}_CRITICAL()) can be a good idea. |
My understanding is that BaseType_t is intended to normally be a type that is a "natural" size for the processor, and thus normally atomically accessible. But, it is possible that it might not be atomic. First thought is that something like portTICK_TYPE_ENTER_CRITICAL could be defined (that defaults to using a critical section) could be defined such that ports that know that accesses to BaseType_t can be done without a critical section could do so. So, all the task{ENTER|EXIT}CRITICAL calls around a single BaseType_t access could be changed to a portBASETYPE{ENTER|EXIT}_CRITICAL call, that defaults to being defined to just be the critical section, but then the major ports that don't need it can define those operations away. |
@GuilhermeGiacomoSimoes did you raise a PR so we can review your changes? |
The following forum discussion points out a few instances where a critical section is wrapping a write to a variable of BaseType_t. BaseType_t is intended to be a datatype that the architecture will access atomically which should eliminate the need for a critical section.
https://forums.freertos.org/t/seemingly-excessive-use-of-taskenter-critical-and-taskexit-critical-macros-in-the-kernel/20044
The feature request is to remove the excess critical sections identified in the forum post. Please use one PR per "fixed" file to simplify code review and/or roll-back as changes to the critical sections can be tricky to test and review.
The text was updated successfully, but these errors were encountered: