Merge pull request #2248 from pan-/define_stack_stize_for_RTOS_threads_test

Define stack size of the threads spawned by RTOS threads test.
pull/2250/head
Sam Grove 2016-07-26 20:14:51 -05:00 committed by GitHub
commit c24e461be3
1 changed files with 16 additions and 5 deletions

View File

@ -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
@ -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();
}
@ -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();
}
@ -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);
}
@ -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++) {
@ -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();
}