Skip to content

Define stack size of the threads spawned by RTOS threads test. #2248

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

Merged
merged 1 commit into from
Jul 27, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions TESTS/mbedmicro-rtos-mbed/threads/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@
#error [NOT_SUPPORTED] test not supported
#endif

/*
* The stack size is defined in cmsis_os.h mainly dependent on the underlying toolchain and
* the C standard library. For GCC, ARM_STD and IAR it is defined with a size of 2048 bytes
* and for ARM_MICRO 512. Because of reduce RAM size some targets need a reduced stacksize.
*/
#if defined(TARGET_MCU_NRF51822) || defined(TARGET_MCU_NRF52832)
#define STACK_SIZE 512
#else
#define STACK_SIZE DEFAULT_STACK_SIZE
#endif

using namespace utest::v1;

// The counter type used accross all the tests
Expand All @@ -32,7 +43,7 @@ void increment_with_wait(counter_t* counter) {
}

void increment_with_child(counter_t* counter) {
Thread child(counter, increment);
Thread child(counter, increment, osPriorityNormal, STACK_SIZE);
child.join();
}

Expand All @@ -41,7 +52,7 @@ void increment_with_murder(counter_t* counter) {
// take ownership of the counter mutex so it prevent the child to
// modify counter.
LockGuard lock(counter->internal_mutex());
Thread child(counter, increment);
Thread child(counter, increment, osPriorityNormal, STACK_SIZE);
child.terminate();
}

Expand All @@ -52,7 +63,7 @@ void increment_with_murder(counter_t* counter) {
template <void (*F)(counter_t *)>
void test_single_thread() {
counter_t counter(0);
Thread thread(&counter, F);
Thread thread(&counter, F, osPriorityNormal, STACK_SIZE);
thread.join();
TEST_ASSERT_EQUAL(counter, 1);
}
Expand All @@ -63,7 +74,7 @@ void test_parallel_threads() {
Thread *threads[N];

for (int i = 0; i < N; i++) {
threads[i] = new Thread(&counter, F);
threads[i] = new Thread(&counter, F, osPriorityNormal, STACK_SIZE);
}

for (int i = 0; i < N; i++) {
Expand All @@ -79,7 +90,7 @@ void test_serial_threads() {
counter_t counter(0);

for (int i = 0; i < N; i++) {
Thread thread(&counter, F);
Thread thread(&counter, F, osPriorityNormal, STACK_SIZE);
thread.join();
}

Expand Down