Generate reusable, multi-instance code that is reentrant.
Generate reentrant code when you want to:
Deploy your code in multi-threaded environments.
Share the same algorithm with different persistent
data.
Compile code that uses function variables that are
too large to fit on the stack.
Tradeoffs to Consider
If you do not choose to generate reentrant code, MATLAB
Coder generates
code that uses statically allocated memory for function variables
that are too large to fit on the stack, and for global and persistent
variables. The use of static memory allocation for these variables
means that you cannot deploy the generated code in environments that
require code to be reentrant. In addition, the generated code can
result in static memory size overflow if you cannot adjust the static
memory allocation size to accommodate the static memory requirements
of the program. When you generate reentrant code, codegen creates
input data structures for function variables that are too large to
fit on the stack, and for persistent and global variables. You can
then dynamically allocate memory for these input structures. The use
of dynamic memory allocation means that you can deploy the code in
reentrant environments.