mirror of https://github.com/ARMmbed/mbed-os.git
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
commit
c24e461be3
|
@ -10,6 +10,17 @@
|
||||||
#error [NOT_SUPPORTED] test not supported
|
#error [NOT_SUPPORTED] test not supported
|
||||||
#endif
|
#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;
|
using namespace utest::v1;
|
||||||
|
|
||||||
// The counter type used accross all the tests
|
// 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) {
|
void increment_with_child(counter_t* counter) {
|
||||||
Thread child(counter, increment);
|
Thread child(counter, increment, osPriorityNormal, STACK_SIZE);
|
||||||
child.join();
|
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
|
// take ownership of the counter mutex so it prevent the child to
|
||||||
// modify counter.
|
// modify counter.
|
||||||
LockGuard lock(counter->internal_mutex());
|
LockGuard lock(counter->internal_mutex());
|
||||||
Thread child(counter, increment);
|
Thread child(counter, increment, osPriorityNormal, STACK_SIZE);
|
||||||
child.terminate();
|
child.terminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +63,7 @@ void increment_with_murder(counter_t* counter) {
|
||||||
template <void (*F)(counter_t *)>
|
template <void (*F)(counter_t *)>
|
||||||
void test_single_thread() {
|
void test_single_thread() {
|
||||||
counter_t counter(0);
|
counter_t counter(0);
|
||||||
Thread thread(&counter, F);
|
Thread thread(&counter, F, osPriorityNormal, STACK_SIZE);
|
||||||
thread.join();
|
thread.join();
|
||||||
TEST_ASSERT_EQUAL(counter, 1);
|
TEST_ASSERT_EQUAL(counter, 1);
|
||||||
}
|
}
|
||||||
|
@ -63,7 +74,7 @@ void test_parallel_threads() {
|
||||||
Thread *threads[N];
|
Thread *threads[N];
|
||||||
|
|
||||||
for (int i = 0; i < N; i++) {
|
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++) {
|
for (int i = 0; i < N; i++) {
|
||||||
|
@ -79,7 +90,7 @@ void test_serial_threads() {
|
||||||
counter_t counter(0);
|
counter_t counter(0);
|
||||||
|
|
||||||
for (int i = 0; i < N; i++) {
|
for (int i = 0; i < N; i++) {
|
||||||
Thread thread(&counter, F);
|
Thread thread(&counter, F, osPriorityNormal, STACK_SIZE);
|
||||||
thread.join();
|
thread.join();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue