Using the NicheStack TCP/IP Stack - Nios II Edition Tutorial

ID 683574
Date 10/04/2021
Public
Document Table of Contents

1.7.5. Task Stack Size

Task stack space requirements depend on how the Nios II processor, HAL, RTOS, and individual software components are configured. A quick empirical check of the Stk[] array values at runtime, through the Nios II SBT for Eclipse memory window, is an easy way to examine the top of a task stack. Examination of a task’s Stk[] array reveals differing values representing the used portion of the stack followed by multiple zeros where the stack has not yet reached. The number of zeros until the beginning of the next adjacent task stack shows how deep the stack has grown since the last system reset.

All tasks that make run-time library calls have space allocated from the top of the stack for the approximately 900-byte _reent structure. Each task has its own copy of the structure positioned on the task’s stack. The size of this structure alone reduces the amount of available stack space.

For more information about the _reent structure, refer to the “The Newlib ANSI C Standard Library” and the “Implementing MicroC/OS-II Projects for the Nios II Processor” sections of the MicroC/OS-II Real-Time Operating System chapter of the Nios II Software Developer’s Handbook.