[En-Nut-Discussion] Use of alloca in Nut/OS

Henrik Maier hmlists at focus-sw.com
Mon Aug 11 02:51:57 CEST 2008


Hi Ole,

> We just differentiate between GNU and IMAGECRAFT in the usage of alloca.
> Imagefcraft does not support alloca as well.
> 
> That's right. My intention was to speedup the code by using alloca for
> dynamic allocation of just small amounts of stack for temporaly holding
> a short string. Using NutHeapAlloc is much slower and will potentially
> fragment the heap if some other heap is allocated in the meanwhile.

I agree with those reasons and in principal stack allocation has benefits.
The challenge is to balance both requirements.

> Would be an idea. I even would vote to use it in more places, but that's
> only possible if every compiler would support alloca. Perhaps we could
> add our own alloca implementation? (By just moving the stack pointer by
> x bytes). Shure, it does not help on systems with low memory...
> Any more thoughts on it?

I suggest to leave it to the system designer (the person who configures
Nut/OS for a particular platform) to decide which way to go. That means an
entry in the Configurator rather using magic pre-processor definitions.
There are also ARM based systems out there with only 32K of RAM where the
thread stack space may only be 512 bytes.

Henrik





More information about the En-Nut-Discussion mailing list