Skip to content

Commit 9e16ef7

Browse files
committed
Reduce the memory footprint of this app
These changes will make the port to an ARMv7-M target easier.
1 parent d30290a commit 9e16ef7

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

source/led1.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ static void led1_main(const void *)
3131
SecureAllocator alloc = secure_allocator_create_with_pages(4 * kB, 1 * kB);
3232

3333
while (1) {
34-
static const size_t size = 500;
34+
static const size_t size = 50;
3535
uint16_t seed = (size << 8) | (uvisor_ctx->heartbeat & 0xFF);
3636

3737
led1 = !led1;

source/led2.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ static void led2_main(const void *);
1818
* We do not need large stacks in either the main nor the interrupt thread, as
1919
* we do not do anything special in them. */
2020
UVISOR_BOX_NAMESPACE(NULL);
21-
UVISOR_BOX_HEAPSIZE(8 * 1024);
21+
UVISOR_BOX_HEAPSIZE(3 * 1024);
2222
UVISOR_BOX_MAIN(led2_main, osPriorityNormal, 512);
2323
UVISOR_BOX_CONFIG(box_led2, acl, 512, box_context);
2424

@@ -47,7 +47,7 @@ static void led2_main(const void *)
4747
secure_allocator_destroy(alloc2);
4848

4949
while (1) {
50-
static const size_t size = 300;
50+
static const size_t size = 30;
5151
uint16_t seed = (size << 8) | (uvisor_ctx->heartbeat & 0xFF);
5252

5353
led2 = !led2;

source/led3.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ static void led3_main(const void *);
1818
* We need at least 1kB in the main thread as we use printf in it. The interrupt
1919
* stack size can be smaller as we do not do anything special in them. */
2020
UVISOR_BOX_NAMESPACE(NULL);
21-
UVISOR_BOX_HEAPSIZE(8 * 1024);
21+
UVISOR_BOX_HEAPSIZE(3 * 1024);
2222
UVISOR_BOX_MAIN(led3_main, osPriorityNormal, 1024);
2323
UVISOR_BOX_CONFIG(box_led3, acl, 512, box_context);
2424

@@ -59,7 +59,7 @@ static void led3_main(const void *)
5959
SecureAllocator alloc = secure_allocator_create_with_pages(4 * kB, 1 * kB);
6060
/* Prepare the thread definition structure. */
6161
osThreadDef_t thread_def;
62-
thread_def.stacksize = DEFAULT_STACK_SIZE;
62+
thread_def.stacksize = 512;
6363
/* Allocate the stack inside the page allocator! */
6464
thread_def.stack_pointer = (uint32_t *) secure_malloc(alloc, DEFAULT_STACK_SIZE);
6565
thread_def.tpriority = osPriorityNormal;

source/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ static void main_alloc(void)
3434
SecureAllocator alloc = secure_allocator_create_with_pages(4 * kB, 1 * kB);
3535

3636
while (1) {
37-
alloc_fill_wait_verify_free(500, seed, 577);
37+
alloc_fill_wait_verify_free(50, seed, 577);
3838
specific_alloc_fill_wait_verify_free(alloc, 5 * kB, seed, 97);
3939
seed++;
4040
}

0 commit comments

Comments
 (0)