[En-Nut-Discussion] ARM Alignment for Threads

Ole Reinhardt ole.reinhardt at embedded-it.de
Thu Oct 10 13:46:18 CEST 2013

Hi all,

>> My ugly hack was to set NUTMEM_ALIGNMENT to 8, and then to add 4 bytes of padding in HEAPNODE between 'size' and 'next'. The result is that threads get a stack that's aligned to 8 bytes, and va_arg() seems to work.
> Consumes more RAM, but should serve well as a temporary work-around. I'd
> suggest to make this the default for Cortex until someone presents a
> better solution. Uwe, Ole, what do you think?

Yes! I will implement it this evening, if you dont mind.

Do we need it on AT91 (and other ARMs) as well?

>> A more elegant solution should be found, but I'm under the gun right now...
> The Nut/OS heap management is intentionally simple. Not very responsive,
> but it has been proven to be very reliable. For example, I never
> experienced any fragmentation problems so far.
> I'm very skeptical about any "new features". Except those features,
> which improve debugging capabilities, because heap corruption is the
> major cause of crashing applications.
> If we think about more elegant solutions, we should check, whether it
> makes still sense to allocate the thread stack from heap. For example,
> the application may provide a pointer to the stack when creating the
> thread. Furthermore, I recently did some research on shared stacks.

Do you just have any findings or ideas how to improve stack allocation
you can just share with us? Thinks would get easier with an MMU, but a
well-working shared stack could be an interesting option as well even
though not easy to implement and perhaps even more error prone to

> The long and short of it: IMHO there is more potential in reconsidering
> the stack creation than in enhancing the heap management.




kernel concepts GmbH            Tel: +49-271-771091-14
Sieghuetter Hauptweg 48         Mob: +49-177-7420433
D-57072 Siegen

More information about the En-Nut-Discussion mailing list