You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2016/03/15 01:36:31 UTC

[24/42] incubator-mynewt-core git commit: Revert changes to the stack sizes since they will have a detrimental effect on low memory embedded platforms.

Revert changes to the stack sizes since they will have a detrimental effect
on low memory embedded platforms.

Scale up the stack size in sim-specific OS_STACK_ALIGN() to ensure that there
is sufficient space on sim targets.

Fix uart_poller so it computes the stack size via the OS_STACK_ALIGN() macro.

Requested by: mkiiskila@github


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/2d2a07ad
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/2d2a07ad
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/2d2a07ad

Branch: refs/heads/master
Commit: 2d2a07ad88de8dc8f5bba4bc78a7ade0f07e41d0
Parents: adbc585
Author: Neel Natu <ne...@nahannisys.com>
Authored: Fri Mar 11 11:24:50 2016 -0800
Committer: Christopher Collins <cc...@gmail.com>
Committed: Fri Mar 11 12:16:13 2016 -0800

----------------------------------------------------------------------
 apps/slinky/src/main.c                   |  8 ++++----
 hw/mcu/native/src/hal_uart.c             |  2 +-
 libs/os/include/os/arch/sim/os/os_arch.h | 14 +++++++++++++-
 3 files changed, 18 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2d2a07ad/apps/slinky/src/main.c
----------------------------------------------------------------------
diff --git a/apps/slinky/src/main.c b/apps/slinky/src/main.c
index 4534097..edaad80 100755
--- a/apps/slinky/src/main.c
+++ b/apps/slinky/src/main.c
@@ -45,24 +45,24 @@ int init_tasks(void);
 
 /* Task 1 */
 #define TASK1_PRIO (1)
-#define TASK1_STACK_SIZE    OS_STACK_ALIGN(1024)
+#define TASK1_STACK_SIZE    OS_STACK_ALIGN(128)
 struct os_task task1;
 os_stack_t stack1[TASK1_STACK_SIZE];
 static volatile int g_task1_loops;
 
 /* Task 2 */
 #define TASK2_PRIO (2)
-#define TASK2_STACK_SIZE    OS_STACK_ALIGN(1024)
+#define TASK2_STACK_SIZE    OS_STACK_ALIGN(128)
 struct os_task task2;
 os_stack_t stack2[TASK2_STACK_SIZE];
 
 #define SHELL_TASK_PRIO (3)
 #define SHELL_MAX_INPUT_LEN     (256)
-#define SHELL_TASK_STACK_SIZE (OS_STACK_ALIGN(1024))
+#define SHELL_TASK_STACK_SIZE (OS_STACK_ALIGN(384))
 os_stack_t shell_stack[SHELL_TASK_STACK_SIZE];
 
 #define NEWTMGR_TASK_PRIO (4)
-#define NEWTMGR_TASK_STACK_SIZE (OS_STACK_ALIGN(1024))
+#define NEWTMGR_TASK_STACK_SIZE (OS_STACK_ALIGN(512))
 os_stack_t newtmgr_stack[NEWTMGR_TASK_STACK_SIZE];
 
 struct log_handler log_console_handler;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2d2a07ad/hw/mcu/native/src/hal_uart.c
----------------------------------------------------------------------
diff --git a/hw/mcu/native/src/hal_uart.c b/hw/mcu/native/src/hal_uart.c
index e2bfc6d..dae24c7 100644
--- a/hw/mcu/native/src/hal_uart.c
+++ b/hw/mcu/native/src/hal_uart.c
@@ -35,7 +35,7 @@
 #include <string.h>
 
 #define UART_MAX_BYTES_PER_POLL	64
-#define UART_POLLER_STACK_SZ	(1024)
+#define UART_POLLER_STACK_SZ	OS_STACK_ALIGN(1024)
 #define UART_POLLER_PRIO	0
 
 struct uart {

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2d2a07ad/libs/os/include/os/arch/sim/os/os_arch.h
----------------------------------------------------------------------
diff --git a/libs/os/include/os/arch/sim/os/os_arch.h b/libs/os/include/os/arch/sim/os/os_arch.h
index cfe737f..59096f8 100644
--- a/libs/os/include/os/arch/sim/os/os_arch.h
+++ b/libs/os/include/os/arch/sim/os/os_arch.h
@@ -40,8 +40,20 @@ typedef unsigned int os_stack_t;
 #define OS_SANITY_STACK_SIZE (1024)
 #define OS_IDLE_STACK_SIZE (1024)
 
+/*
+ * The 'sim' architecture-specific code does not have as much control on
+ * stack usage as the real embedded architectures.
+ *
+ * For e.g. the space occupied by the signal handler frame on the task
+ * stack is entirely dependent on the host OS.
+ *
+ * Deal with this by scaling the stack size by a factor of 16. The scaling
+ * factor can be arbitrarily large because the stacks are allocated from
+ * BSS and thus don't add to either the executable size or resident
+ * memory.
+ */
 #define OS_STACK_ALIGN(__nmemb) \
-    (OS_ALIGN((__nmemb), OS_STACK_ALIGNMENT))
+    (OS_ALIGN(((__nmemb) * 16), OS_STACK_ALIGNMENT))
 
 /* Enter a critical section, save processor state, and block interrupts */
 #define OS_ENTER_CRITICAL(__os_sr) (__os_sr = os_arch_save_sr())