comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Clubley <clubley@remove_me.eisner.decus.org-Earth.UFP>
Subject: Re: Ada-Comment proposals (version 3)
Date: Sun, 13 Jul 2014 18:16:50 +0000 (UTC)
Date: 2014-07-13T18:16:50+00:00	[thread overview]
Message-ID: <lpuieh$5pr$1@dont-email.me> (raw)
In-Reply-To: c2fvciFm8uiU1@mid.individual.net

On 2014-07-13, Niklas Holsti <niklas.holsti@tidorum.invalid> wrote:
> On 14-07-13 19:54 , Simon Clubley wrote:
>> I've restructured issue 1 to turn it into a general partial aggregates
>> proposal. The atomic updating of device register bitfields discussion
>> is still pretty much the same but the additional comments and examples
>> from Niklas make it a more general proposal.
>> 
>> Niklas, since I have included your words and examples directly, can you
>> make sure you are happy with what I have included please ?
>
> Quite ok, thanks. I have just one additional comment:
>
>> For an Atomic record, the compiler would generate a Read-Modify-Write
>> sequence
>
> I'm afraid that saying "Read-Modify-Write" may be misunderstood to mean
> a fully atomic update, not just an atomic read followed by an atomic
> write of a new value, where other accesses to the record variable can
> occur between the read and the write. Wikipedia defines
> "read-modify-write" as an atomic update, giving the "test-and-set"
> instruction type as one example.
>

This was one of the things which was discussed with Randy a few days
ago. At that time, it was made clear by Randy that Atomic, as applied
to Ada, only ever meant the read was atomic and the write was atomic.
The overall sequence itself is never considered to be an atomic
operation.

I'll see about tweaking the language to make that more clearer however.

> It would be safer to write something like this: "the compiler would
> generate an atomic read of the whole record variable into a
> compiler-created temporary (perhaps a register), followed by an update
> of the temporary according to the component updates listed in the
> partial aggregate, and ending by an atomic write of the whole updated
> value into the record variable".
>
> This brings to mind an interesting question: if the processor has some
> fully atomic read-modify-write instructions, and the semantics of one of
> these instructions matches the way the record variable is updated with a
> partial aggregate, is the compiler allowed to use that read-modify-write
> instruction? I don't know if such instructions always work with
> memory-mapped peripheral registers -- for example, their timing in terms
> of clocks between the read and the write may be different.
>

We would have to be _very_ careful here that we didn't introduce
behaviour which could be platform specific.

For example, we would not want people to write code which didn't
consider what happens during an interrupt simply because that wasn't
an issue on the original platform due to the generated code emitted
by the compiler.

And yes, I know that people should not be writing code which depends
on compiler behaviour. :-)

Simon.

-- 
Simon Clubley, clubley@remove_me.eisner.decus.org-Earth.UFP
Microsoft: Bringing you 1980s technology to a 21st century world


  reply	other threads:[~2014-07-13 18:16 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-13 16:54 Ada-Comment proposals (version 3) Simon Clubley
2014-07-13 17:53 ` Niklas Holsti
2014-07-13 18:16   ` Simon Clubley [this message]
2014-07-13 21:05     ` Niklas Holsti
2014-07-13 23:45       ` Simon Clubley
2014-07-14  0:24 ` Simon Clubley
2014-07-15 17:20   ` Simon Clubley
2014-07-15 22:11     ` Randy Brukardt
2014-07-15 23:15       ` Simon Clubley
2014-07-15 23:39         ` Adam Beneschan
2014-07-15 23:50           ` Adam Beneschan
2014-07-16  0:05             ` Simon Clubley
2014-07-21 22:02             ` Randy Brukardt
2014-07-21 22:09               ` Simon Wright
2014-07-22  0:26                 ` Randy Brukardt
2014-07-15 23:53           ` Simon Clubley
2014-07-21 22:20             ` Randy Brukardt
2014-07-21 23:06               ` Simon Clubley
2014-07-22  0:24                 ` Randy Brukardt
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox