mirror of https://github.com/ARMmbed/mbed-os.git
Define stack size of the threads spawned by this test.
This stack size is adjusted for NRF51 and NRF52 based targets.pull/2248/head
parent
0675a58009
commit
2099da6d58
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue