APPENDIX D STACK SIZE ESTIMATION
If a stack overflows, the behavior of the system becomes irregular. Therefore, a stack must not overflow referring to this chapter.
There are two types of stacks: the user stack and system stack. The method for calculating stack sizes differs between the user stack and system stack.
- User stack
The stack used by tasks is called "User stack". When a task is created by
Task Information (task[]), the size and the name of the section where the stack is allocated are specified.
The CubeSuite+ package includes "Call Walker" which is a utility tool to calculate stack size.
The Call Walker can display stack size used by each function tree.
D.3 User Stack Size Estimation
The quantity consumed of user stack for each task is calculated by the following expressions.
Quantity consumed of user stack =
treesz +
ctxsz
-
treesz
Size consumed by function tree that makes the task entry function starting point. (the size displayed by Call Walker).
Table D-1 Size of Task Context Register
Setting of system.context
|
|
Size of Task Contest Register
|
|
|
|
|
|
|
|
|
|
"-isa=rxv1" or not specify "-isa"
|
|
|
|
|
"-isa=rxv1" or not specify "-isa"
|
|
|
|
|
|
|
|
|
|
|
"-isa=rxv1" or not specify "-isa"
|
|
|
|
|
"-isa=rxv1" or not specify "-isa"
|
|
Note Compiler option "-isa" is supported by the compiler CC-RX V2.01 or later.
D.4 System Stack Size Estimation
The system stack is most consumed when an interrupt occurs during service call processing followed by the occurrence of multiple interrupts. The quantity consumed of system stack is calculated by the following expressions.
Quantity consumed of system stack = |
|
svcsz |
|
|
15 |
|
+ |
∑ |
inthdrsz k |
|
|
k = 1 |
|
+ sysdwnsz |
-
svcsz
The maximum size among the service calls to be used in the all processing program. The value
svcsz depends on the RI600V4 version. For details, refer to release notes.
-
inthdrsz
Size consumed by function tree that makes the interrupt handler entry function starting point. (the size displayed by Call Walker).
The "k" means interrupt priority level. If there are multiple interrupts in the same priority level, the
inthdrsz k should select the maximum size among the handlers.
The size used by the base clock interrupt handler (the interrupt priority level is specified by
Base clock interrupt priority level (IPL) in
Base Clock Interrupt Information (clock)) is the maximum value in the following Please refer to the release notes for
clocksz1,
clocksz2 and
clocksz3.
Don't have to add the size used by the base clock interrupt handler when base clock timer is not used (clock.timer = NOTIMER).
-
cycsz
Size consumed by function tree that makes the cyclic handler entry function starting point. (the size displayed by Call Walker).
If there are multiple cyclic handlers, the
cycsz should select the maximum size among the handlers.
-
almsz
Size consumed by function tree that makes the alarm handler entry function starting point. the size displayed by Call Walker).
If there are multiple alarm handlers, the
cycsz should select the maximum size among the handlers.
-
sysdwnsz
Size consumed by function tree that makes the system down routine entry function starting point. (the size displayed by Call Walker) + 40. When the system down routine has never been executed,
sysdwnsz is assumed to be 0.