public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: David Brown <david.brown@hesbynett.no>
To: Jonathan Wakely <jwakely.gcc@gmail.com>
Cc: gcc-help <gcc-help@gcc.gnu.org>
Subject: Re: Atomic accesses on ARM microcontrollers
Date: Sun, 11 Oct 2020 12:54:00 +0200	[thread overview]
Message-ID: <75fe5a26-1201-eb90-45a2-e6477204d9fd@hesbynett.no> (raw)
In-Reply-To: <CAH6eHdRJxBgkhbhjuY2VSjOs5xqXdOhnOW9u3a9BqC1qs=hoUw@mail.gmail.com>


On 10/10/2020 22:18, Jonathan Wakely wrote:
> On Sat, 10 Oct 2020 at 20:43, David Brown <david.brown@hesbynett.no> wrote:
>> Is this strategy guaranteed to work in gcc, or is it a case of "it works
>> in a simple test, but might fail in a complicated program or with
>> different flags" ?
> 
> I think it works by design. My understanding is that users providing
> their own implementation of those calls is fully supported. I think
> that's partly why libatomic.so is a distinct library, and not just
> part of libgcc_s.so. The docs aren't entirely clear about this, they
> just say that if the compiler can't emit lock-free instructions for
> the atomic operation "a call is made to an external routine with the
> same parameters to be resolved at run time." But I think that "to be
> resolved at run time" means that you can choose how those calls will
> be resolved.
> 

Thank you for that - this sounds like the way to go for my code.

And I suppose I should file a bug report for the current libatomic that
comes with gcc.  It would be much better to have no support by default
than to have the current spinlocks - as it stands, on a microcontroller
like mine, it will all appear to work during development and most
testing.  But if in normal processing the code takes the spinlock and
then there is an interrupt whose handler tries to access the same atomic
(or at least one that shares the same lock), the interrupt handler will
be stalled forever.

David

  reply	other threads:[~2020-10-11 10:54 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-09 18:28 David Brown
2020-10-09 23:28 ` Segher Boessenkool
2020-10-10 12:39 ` Jonathan Wakely
2020-10-10 19:43   ` David Brown
2020-10-10 20:18     ` Jonathan Wakely
2020-10-11 10:54       ` David Brown [this message]
2020-10-12  7:17     ` David Brown
2020-10-12 21:44   ` Patrick Oppenlander
     [not found] ` <b29b1595-9441-68eb-f257-244a35082c82@winterflaw.net>
2020-10-10 19:43   ` David Brown
2020-10-10 20:09     ` Jonathan Wakely
     [not found]     ` <bdf0f96f-0377-bee7-c02e-9704f0bea6a5@winterflaw.net>
2020-10-11 12:16       ` David Brown
     [not found]         ` <24c49c76-43c3-9a0d-6b02-a4340b1fccba@winterflaw.net>
2020-10-11 12:51           ` David Brown
2020-10-13 11:46             ` Richard Earnshaw

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=75fe5a26-1201-eb90-45a2-e6477204d9fd@hesbynett.no \
    --to=david.brown@hesbynett.no \
    --cc=gcc-help@gcc.gnu.org \
    --cc=jwakely.gcc@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).