Dynamic Stack Pointer Switching for Embedded Memory Overflow
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Embedded systems face challenges in executing generic application software due to limited stack size in internal memory, leading to overflow issues, and existing solutions to expand internal memory are costly.
Innovation Solution
A method that dynamically changes the stack pointer from internal to external memory during task execution, allowing temporary information to be stored in external memory, thereby avoiding the need to increase internal memory size and reducing costs.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Reliability
If the stack size is increased by expanding internal memory capacity, then stack overflow is prevented, but the cost of the embedded system increases greatly
Solution Approach 1:
The patent implements dynamic stack pointer switching between internal and external memory based on execution context. The stack pointer is changed from pointing to internal memory to external memory before executing functions that require large stack space, and switched back after execution. This dynamic allocation allows the system to use external memory only when needed, avoiding the need to permanently expand internal memory capacity and thus reducing system cost while preventing stack overflow.
Solution Approach 2:
The patent introduces external memory as an intermediary storage space to handle stack overflow scenarios. Instead of permanently expanding the internal memory, the system uses external memory as a temporary storage destination when the stack exceeds internal memory capacity. This intermediary approach allows the embedded system to accommodate larger stack requirements without increasing the base internal memory configuration, thereby maintaining cost-effectiveness.
2Quantity of substance
If the internal memory capacity is expanded to accommodate larger stack, then the stack can store more temporary information, but the cost increases and the simpler OS architecture is compromised
Solution Approach 1:
The patent employs dynamic stack pointer switching to allocate stack space on demand. The stack pointer dynamically changes between internal and external memory based on the execution context of different functions. This dynamic mechanism allows the system to achieve larger effective stack capacity without permanently expanding internal memory or complicating the base memory architecture, as the switching is managed through software control rather than hardware reconfiguration.
Data Source
AI summary
A control apparatus, an integrated circuit, and a management method for a stack are provided. The management method for the stack includes: obtaining an instruction of running a task with a first function; changing a pointer of the stack in an internal memory from pointing to an internal memory to an external memory before executing the first function, wherein the stack in the internal memory is used by the task; executing the first function, wherein first temporary information that is needed to be stored during a period of executing the first function is stored into the external memory pointed to by the pointer of stack; and adjusting the pointer of the stack to point to the internal memory after finishing executing the first function. According to the above-mentioned management method for the stack, the cost is reduced, and low power consumption can be achieved.


