15
15
* the C standard library. For GCC, ARM_STD and IAR it is defined with a size of 2048 bytes
16
16
* and for ARM_MICRO 512. Because of reduce RAM size some targets need a reduced stacksize.
17
17
*/
18
- #if defined(TARGET_MCU_NRF51822) || defined(TARGET_MCU_NRF52832)
19
- #define STACK_SIZE 512
20
- #elif defined(TARGET_STM32F070RB) || defined(TARGET_STM32F072RB) || defined(TARGET_STM32F103RB) || defined(TARGET_STM32F091RC)
21
- #define STACK_SIZE 512
22
- #elif defined(TARGET_STM32F410RB)
23
- #define STACK_SIZE 512
24
- #elif defined(TARGET_STM32L073RZ)
25
- #define STACK_SIZE 512
26
- #elif defined(TARGET_XDOT_L151CC)
27
- #define STACK_SIZE 1024
28
- #elif defined(TARGET_HI2110)
29
- #define STACK_SIZE 512
30
- #elif defined(TARGET_EFR32)
31
- #define STACK_SIZE 512
32
- #else
33
- #define STACK_SIZE DEFAULT_STACK_SIZE
34
- #endif
18
+ #define PARALLEL_STACK_SIZE 512
35
19
36
20
using namespace utest ::v1;
37
21
@@ -55,7 +39,7 @@ void increment_with_wait(counter_t* counter) {
55
39
}
56
40
57
41
void increment_with_child (counter_t * counter) {
58
- Thread child (counter, increment, osPriorityNormal, STACK_SIZE );
42
+ Thread child (counter, increment);
59
43
child.join ();
60
44
}
61
45
@@ -64,7 +48,7 @@ void increment_with_murder(counter_t* counter) {
64
48
// take ownership of the counter mutex so it prevent the child to
65
49
// modify counter.
66
50
LockGuard lock (counter->internal_mutex ());
67
- Thread child (counter, increment, osPriorityNormal, STACK_SIZE );
51
+ Thread child (counter, increment);
68
52
child.terminate ();
69
53
}
70
54
@@ -81,7 +65,7 @@ void self_terminate(Thread *self) {
81
65
template <void (*F)(counter_t *)>
82
66
void test_single_thread () {
83
67
counter_t counter (0 );
84
- Thread thread (&counter, F, osPriorityNormal, STACK_SIZE );
68
+ Thread thread (&counter, F);
85
69
thread.join ();
86
70
TEST_ASSERT_EQUAL (counter, 1 );
87
71
}
@@ -92,7 +76,7 @@ void test_parallel_threads() {
92
76
Thread *threads[N];
93
77
94
78
for (int i = 0 ; i < N; i++) {
95
- threads[i] = new Thread (&counter, F, osPriorityNormal, STACK_SIZE );
79
+ threads[i] = new Thread (&counter, F, osPriorityNormal, PARALLEL_STACK_SIZE );
96
80
}
97
81
98
82
for (int i = 0 ; i < N; i++) {
@@ -108,15 +92,15 @@ void test_serial_threads() {
108
92
counter_t counter (0 );
109
93
110
94
for (int i = 0 ; i < N; i++) {
111
- Thread thread (&counter, F, osPriorityNormal, STACK_SIZE );
95
+ Thread thread (&counter, F);
112
96
thread.join ();
113
97
}
114
98
115
99
TEST_ASSERT_EQUAL (counter, N);
116
100
}
117
101
118
102
void test_self_terminate () {
119
- Thread *thread = new Thread (osPriorityNormal, STACK_SIZE );
103
+ Thread *thread = new Thread (osPriorityNormal);
120
104
thread->start (thread, self_terminate);
121
105
thread->join ();
122
106
delete thread;
0 commit comments