Skip to Main Content
Typical sensor nodes have a small amount of memory with 2-10 KB and even no hardware devices for memory protection such as MMU. Consider multi-threaded sensor applications running on such a memory-constrained hardware platform. In most sensor operating systems, it is assumed that thread stacks are statically allocated. However, this static allocation is not appropriate for memory constrained sensor hardware because shortage of stack memory space can bring in the stack overflow problem. As an alternative method, this paper proposes a dynamic stack allocating method, which enables to adaptively adjust the stack size of each threads based on the stack usage information. The information of the stack usage is obtained by measurement at run-time. The proposed method also defines a stack reallocating problem and solves it in n steps, where n is the number of thread stacks. Our experimental results showed that the proposed method significantly minimizes the waste of thread stack memory space compared to the static stack allocating method.