apps/ostest: add fail detect and print for roundrobin case. #3227
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
If the round robin is work as expected, the g_rr_value_index atomic and g_rr_values should record different thread be swapped.
And if not working, the g_rr_values will record all thread run and finish one by one. then able to be catch by the code before return.
Also when SMP, two thread able to run in two cores, the case still not able to catch problems.
Add pthread_attr_setaffinity_np to ensure when SMP it still working.
As we rely on the get_primes_thread calulation speed and rr_inerval Kconfig, value, it depend on the cpu performance, so
change TESTING_OSTEST_RR_RANGE default value from 10000 to 30000, to ensure most scene, the default 200ms rr interval able to make get_primes_thread do at least one swap.
Impact
Before patch we never detect the roundrobin fail.
After patch we able to report if the rondrobin not able to successfully trigger context switch even the thread just normal running.
In self environment rr_test time cost from 100ms to 900ms for extra time cost.
Testing
CI-test, self test for qemu armv7a nsh & smp.
manually allow case run when round robin not enabled to ensure it can catch the fail case.