-
Notifications
You must be signed in to change notification settings - Fork 163
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
Optimize uxStreamBufferAdd() locking mechanism #1181
Conversation
Thanks for taking time to contribute to FreeRTOS+TCP. |
Hello @lzungri, thank you for presenting your PR. In order to make a critical section, this library prefers to suspend the scheduler, rather than masking interrupts. The library is used on many platforms, and often, FreeRTOS users want an optimal ISR response time by masking interrupts as little and as shortly as possible. It must be said that Tony wrote:
I'm curious about that test. Thanks |
Thanks for taking a look at it.
Agreed. If used incorrectly, Speaking of which, there are several other places where I think
Just to name a few. Maybe this should be part of a bigger "Performance improvements" PR. |
I see the choice depends on a combination of 3 factors:
|
The changes look good; disabling interrupts is faster than suspending the scheduler and resuming it back. Also, are you willing to make similar changes (that you have listed in the previous comment) where the protected region is short and time-bound as well, maybe in a different PR or as part of this PR? |
@tony-josi-aws I may be able to work on that in a week or two (in a new PR). |
Thank you. |
To optimize performance, consider replacing the potentially costly
vTaskSuspendAll
/xTaskResumeAll
locking mechanism with the more efficienttaskENTER_CRITICAL
/taskEXIT_CRITICAL
pair.While
taskENTER_CRITICAL
disables interrupts, the protected code section is relatively short and time-bound, making it a suitable candidate. This is especially advantageous given the high-frequency usage ofuxStreamBufferAdd()
.