This is the mail archive of the mailing list for the eCos project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Thread stack alignment requirements for ARM

On 23.06.2011 04:37, Michael Bergandi wrote:

> According to the ARM site, they say that stacks should be 16 byte
> aligned. Then, they go on to say that there are a couple ways that
> stack alignment requirement can be managed. One of which was if you
> are running on an OS and the OS has taken steps to ensure the
> requirement is met, then the application need not worry about it. I
> don't think I fully understand what this means exactly.

HAL_THREAD_INIT_CONTEXT forces the alignment of the stack - see e.g.

register CYG_WORD _sp_ = ((CYG_WORD)_sparg_) &~15;

> Our particular target is the mx27 (ARM9). Out of habit, we make all
> the memory for the thread stacks in our applications 4 byte aligned.
> Is this enough? Is it really necessary?

Yes (but you are eventually wasting up to 12 bytes), no.

The linker script takes care of the sections and the
compiler and standard library (malloc) of the rest of the
alignment needs.

It only matters if you are building some kind of compiler/
linker/dynamic loader functionality or if you are upcasting
some datatypes (such as int * to double *) - I got burned
with this...


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]