-
Notifications
You must be signed in to change notification settings - Fork 3k
mbedmicro-rtos-mbed tests : reduce memory consumption #4890
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,11 @@ | |
#error [NOT_SUPPORTED] test not supported | ||
#endif | ||
|
||
#if defined(TARGET_NUCLEO_F070RB) || defined(TARGET_NUCLEO_F072RB) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The rest of changes are fine. I am not certain about this. Are we expecting to have here ifdef for varios targets . There is not 2x768bytes available for these 2 targets? |
||
#define THREAD_STACK_SIZE 512 | ||
#else | ||
#define THREAD_STACK_SIZE 768 | ||
#endif | ||
|
||
using namespace utest::v1; | ||
|
||
|
@@ -272,7 +276,7 @@ void signal_wait_multibit_tout() | |
template <int S, void (*F)()> | ||
void test_thread_signal() | ||
{ | ||
Thread t_wait; | ||
Thread t_wait(osPriorityNormal, THREAD_STACK_SIZE); | ||
|
||
t_wait.start(callback(F)); | ||
|
||
|
@@ -308,7 +312,7 @@ void signal_clr() | |
*/ | ||
void test_thread_signal_clr() | ||
{ | ||
Thread t_wait; | ||
Thread t_wait(osPriorityNormal, THREAD_STACK_SIZE); | ||
|
||
t_wait.start(callback(signal_clr)); | ||
|
||
|
@@ -412,7 +416,7 @@ void test_deleted_thread() | |
*/ | ||
void test_deleted() | ||
{ | ||
Thread t; | ||
Thread t(osPriorityNormal, THREAD_STACK_SIZE); | ||
|
||
TEST_ASSERT_EQUAL(Thread::Deleted, t.get_state()); | ||
|
||
|
@@ -435,7 +439,7 @@ void test_delay_thread() | |
*/ | ||
void test_delay() | ||
{ | ||
Thread t; | ||
Thread t(osPriorityNormal, THREAD_STACK_SIZE); | ||
|
||
t.start(callback(test_delay_thread)); | ||
|
||
|
@@ -460,7 +464,7 @@ void test_signal_thread() | |
*/ | ||
void test_signal() | ||
{ | ||
Thread t; | ||
Thread t(osPriorityNormal, THREAD_STACK_SIZE); | ||
|
||
t.start(callback(test_signal_thread)); | ||
|
||
|
@@ -484,7 +488,7 @@ void test_evt_flag_thread(osEventFlagsId_t evtflg) | |
*/ | ||
void test_evt_flag() | ||
{ | ||
Thread t; | ||
Thread t(osPriorityNormal, THREAD_STACK_SIZE); | ||
mbed_rtos_storage_event_flags_t evtflg_mem; | ||
osEventFlagsAttr_t evtflg_attr; | ||
osEventFlagsId_t evtflg; | ||
|
@@ -516,7 +520,7 @@ void test_mutex_thread(Mutex *mutex) | |
*/ | ||
void test_mutex() | ||
{ | ||
Thread t; | ||
Thread t(osPriorityNormal, THREAD_STACK_SIZE); | ||
Mutex mutex; | ||
|
||
mutex.lock(); | ||
|
@@ -543,7 +547,7 @@ void test_semaphore_thread(Semaphore *sem) | |
*/ | ||
void test_semaphore() | ||
{ | ||
Thread t; | ||
Thread t(osPriorityNormal, THREAD_STACK_SIZE); | ||
Semaphore sem; | ||
|
||
t.start(callback(test_semaphore_thread, &sem)); | ||
|
@@ -568,7 +572,7 @@ void test_msg_get_thread(Queue<int32_t, 1> *queue) | |
*/ | ||
void test_msg_get() | ||
{ | ||
Thread t; | ||
Thread t(osPriorityNormal, THREAD_STACK_SIZE); | ||
Queue<int32_t, 1> queue; | ||
|
||
t.start(callback(test_msg_get_thread, &queue)); | ||
|
@@ -594,7 +598,7 @@ void test_msg_put_thread(Queue<int32_t, 1> *queue) | |
*/ | ||
void test_msg_put() | ||
{ | ||
Thread t; | ||
Thread t(osPriorityNormal, THREAD_STACK_SIZE); | ||
Queue<int32_t, 1> queue; | ||
|
||
queue.put((int32_t *)0xE1EE7); | ||
|
@@ -642,7 +646,7 @@ void test_thread_ext_stack() { | |
then priority is changed and can be retrieved using @a get_priority | ||
*/ | ||
void test_thread_prio() { | ||
Thread t(osPriorityNormal); | ||
Thread t(osPriorityNormal, THREAD_STACK_SIZE); | ||
t.start(callback(thread_wait_signal)); | ||
|
||
TEST_ASSERT_EQUAL(osPriorityNormal, t.get_priority()); | ||
|
@@ -666,23 +670,23 @@ utest::v1::status_t test_setup(const size_t number_of_cases) { | |
// macros don't play nicely with the templates (extra comma). | ||
static const case_t cases[] = { | ||
{"Testing single thread", test_single_thread<increment>, DEFAULT_HANDLERS}, | ||
{"Testing parallel threads", test_parallel_threads<3, increment> , DEFAULT_HANDLERS}, | ||
{"Testing parallel threads", test_parallel_threads<2, increment> , DEFAULT_HANDLERS}, | ||
{"Testing serial threads", test_serial_threads<10, increment> , DEFAULT_HANDLERS}, | ||
|
||
{"Testing single thread with yield", test_single_thread<increment_with_yield>, DEFAULT_HANDLERS}, | ||
{"Testing parallel threads with yield", test_parallel_threads<3, increment_with_yield>, DEFAULT_HANDLERS}, | ||
{"Testing parallel threads with yield", test_parallel_threads<2, increment_with_yield>, DEFAULT_HANDLERS}, | ||
{"Testing serial threads with yield", test_serial_threads<10, increment_with_yield>, DEFAULT_HANDLERS}, | ||
|
||
{"Testing single thread with wait", test_single_thread<increment_with_wait>, DEFAULT_HANDLERS}, | ||
{"Testing parallel threads with wait", test_parallel_threads<3, increment_with_wait>, DEFAULT_HANDLERS}, | ||
{"Testing parallel threads with wait", test_parallel_threads<2, increment_with_wait>, DEFAULT_HANDLERS}, | ||
{"Testing serial threads with wait", test_serial_threads<10, increment_with_wait>, DEFAULT_HANDLERS}, | ||
|
||
{"Testing single thread with child", test_single_thread<increment_with_child>, DEFAULT_HANDLERS}, | ||
{"Testing parallel threads with child", test_parallel_threads<3, increment_with_child>, DEFAULT_HANDLERS}, | ||
{"Testing parallel threads with child", test_parallel_threads<1, increment_with_child>, DEFAULT_HANDLERS}, | ||
{"Testing serial threads with child", test_serial_threads<10, increment_with_child>, DEFAULT_HANDLERS}, | ||
|
||
{"Testing single thread with murder", test_single_thread<increment_with_murder>, DEFAULT_HANDLERS}, | ||
{"Testing parallel threads with murder", test_parallel_threads<3, increment_with_murder>, DEFAULT_HANDLERS}, | ||
{"Testing parallel threads with murder", test_parallel_threads<1, increment_with_murder>, DEFAULT_HANDLERS}, | ||
{"Testing serial threads with murder", test_serial_threads<10, increment_with_murder>, DEFAULT_HANDLERS}, | ||
|
||
{"Testing thread self terminate", test_self_terminate, DEFAULT_HANDLERS}, | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The large number of threads was specifically chosen to help this test catch race conditions faster and more reliably. When I was testing this with only 2 threads, race conditions wouldn't reliably get caught in the 15 seconds the test ran for. If you want to reduce the number of threads then you'll probably need to increase the test time.
You can verify this test is working by temporarily removing the malloc locks (__malloc_lock and __malloc_unlock) in platform/mbed_retarget.cpp and running this test and waiting for a failure. You should be able to run this test a couple of times with two threads to get the mean time to failure. From that you could then adjust the test time accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jeromecoutant bump
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi
I'm back...
Temp test done (removing malloc locks): either test is failing before first LED blink, either test is OK whatever the duration...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep us updated (as we understand the test is failing?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New commit done.
Test report added.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can be fix in other way than thread number reduction, by removing extraneous heap allocations (by statically allocation of threads stack). PR #5338