Am Thu, 24 Oct 2013 14:04:44 +0100 schrieb Iain Buclaw <[email protected]>:
> On 24 October 2013 12:10, John Colvin > <[email protected]> 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; } ------------------------------------
