ARM bare-metal programming in D (cont) - volatile
Johannes Pfau
nospam at example.com
Thu Oct 24 10:49:54 PDT 2013
Am Thu, 24 Oct 2013 14:04:44 +0100
schrieb Iain Buclaw <ibuclaw at ubuntu.com>:
> On 24 October 2013 12:10, John Colvin
> <john.loughran.colvin at gmail.com> wrote:
> > On Thursday, 24 October 2013 at 09:43:51 UTC, Iain Buclaw wrote:
> >>>>
> >>>> 'shared' guarantees that all reads and writes specified in
> >>>> source code happen in the exact order specified with no omissions
Does this include writes to non-shared data? For example:
------------------------------------
shared int x;
int y;
void func()
{
x = 0;
y = 3; //Can the compiler move this assignment?
x = 1;
}
------------------------------------
So there's no additional overhead (in code / instructions emitted) when
using shared instead of volatile in code like this? And this is valid
code with shared (assuming reading/assigning to x is atomic)?
------------------------------------
volatile bool x = false;
void waitForX()
{
while(!x){}
}
__interrupt(X) void x_interrupt()
{
x = true;
}
------------------------------------
More information about the Digitalmars-d
mailing list