public inbox for ecos-devel@sourceware.org
 help / color / mirror / Atom feed
From: Stanislav Meduna <stano@meduna.org>
To: ecos-devel@ecos.sourceware.org
Cc: Michael Bergandi <mbergandi@gmail.com>
Subject: Re: Thread stack alignment requirements for ARM
Date: Thu, 23 Jun 2011 07:27:00 -0000	[thread overview]
Message-ID: <4E02EAA5.7080405@meduna.org> (raw)
In-Reply-To: <BANLkTinA1-0RC8bVsR4Pp=z+CNKODiizbw@mail.gmail.com>

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.
 packages\hal\arm\arch\current\include\hal_arch.h:

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...

Regards
-- 
                                      Stano

  reply	other threads:[~2011-06-23  7:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-23  2:37 Michael Bergandi
2011-06-23  7:27 ` Stanislav Meduna [this message]
2011-06-23  9:58 ` Nick Garnett
2011-06-23 16:05   ` Michael Bergandi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4E02EAA5.7080405@meduna.org \
    --to=stano@meduna.org \
    --cc=ecos-devel@ecos.sourceware.org \
    --cc=mbergandi@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).