Address Richard's feedback to update the usage of pxCurrentTCB in a function.
Since pxCurrentTCB is a volatile variable, accessing it multiple times can be slow if this pointer is not changed.
In this PR:
Use a const pointer variable to access pxCurrentTCB in a function to prevent multiple accessing a volatile variable.
The prvGetCurrentTaskTCB() and prvGetCurrentTaskTCBUnsafe() functions are provided. prvGetCurrentTaskTCBUnsafe() can improve performance in SMP environments as it does not disable/enable interrupts. However, it should only be called in contexts where race conditions cannot occur.
Test Steps
Performance comparison test.
Checklist:
[ ] I have tested my changes. No regression in existing tests.
[ ] I have modified and/or added unit-tests to cover the code changes in this Pull Request.
Related Issue
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Description
Address Richard's feedback to update the usage of
pxCurrentTCB
in a function. SincepxCurrentTCB
is a volatile variable, accessing it multiple times can be slow if this pointer is not changed.In this PR:
prvGetCurrentTaskTCB()
andprvGetCurrentTaskTCBUnsafe()
functions are provided.prvGetCurrentTaskTCBUnsafe()
can improve performance in SMP environments as it does not disable/enable interrupts. However, it should only be called in contexts where race conditions cannot occur.Test Steps
Performance comparison test.
Checklist:
Related Issue
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.