Re: [go-nuts] About Go 1.19 memory model clarificaitons on atomic operations.

2022-08-16 Thread Andrew Harris
On Monday, August 15, 2022 at 9:50:17 AM UTC-7 jake...@gmail.com wrote: > On Monday, August 15, 2022 at 5:20:58 AM UTC-4 ma...@changkun.de wrote: > >> Atomic operations on a and b are two different statements. It remains >> unclear where exactly is the sentence that tries to say this: atomic >>

Re: [go-nuts] About Go 1.19 memory model clarificaitons on atomic operations.

2022-08-16 Thread Ludi Rehak
The 2nd linked playground program appears to be identical to the program that Russ Cox's memory models part 2 blog opens with: // Thread 1 // Thread 2 x = 1; while(done == 0) { /* loop */ } done = 1;print(x); Just substitu

Re: [go-nuts] About Go 1.19 memory model clarificaitons on atomic operations.

2022-08-15 Thread jake...@gmail.com
On Monday, August 15, 2022 at 5:20:58 AM UTC-4 ma...@changkun.de wrote: > > Any other reading, to me, is trying to find an ambiguity for the sole > sake of finding an ambiguity. > > A reader does not have to be motivated to find ambiguity. If the > sentence can be interpreted with different mea

Re: [go-nuts] About Go 1.19 memory model clarificaitons on atomic operations.

2022-08-15 Thread 'Axel Wagner' via golang-nuts
If you *want* to read the Memory model that way and write your programs accordingly, you are free to do so. I think you'll find that consistently applying that logic will make it impossible to write correct concurrent programs sharing memory though. For example, the section about locks

Re: [go-nuts] About Go 1.19 memory model clarificaitons on atomic operations.

2022-08-15 Thread Changkun Ou
> Any other reading, to me, is trying to find an ambiguity for the sole sake of > finding an ambiguity. A reader does not have to be motivated to find ambiguity. If the sentence can be interpreted with different meanings, other readers may perceive it differently. To me, the first read of this se

Re: [go-nuts] About Go 1.19 memory model clarificaitons on atomic operations.

2022-08-15 Thread 'Axel Wagner' via golang-nuts
On Mon, Aug 15, 2022 at 10:02 AM Changkun Ou wrote: > > The memory operations in each goroutine must correspond to a correct > sequential execution of that goroutine, given the values read from and > written to memory. That execution must be consistent with the sequenced > before relation, define

Re: [go-nuts] About Go 1.19 memory model clarificaitons on atomic operations.

2022-08-15 Thread tapi...@gmail.com
I tend to think it should print 1, as well this one: https://go.dev/play/p/bax7CoaSV1d On Monday, August 15, 2022 at 3:34:35 PM UTC+8 tapi...@gmail.com wrote: > It would be good if the Memory Model article shows some atomic examples. > > On Monday, August 15, 2022 at 3:06:58 PM UTC+8 ma...@chan

Re: [go-nuts] About Go 1.19 memory model clarificaitons on atomic operations.

2022-08-15 Thread Changkun Ou
> The memory operations in each goroutine must correspond to a correct > sequential execution of that goroutine, given the values read from and > written to memory. That execution must be consistent with the sequenced > before relation, defined as the partial order requirements set out by the Go

Re: [go-nuts] About Go 1.19 memory model clarificaitons on atomic operations.

2022-08-15 Thread 'Axel Wagner' via golang-nuts
On Mon, Aug 15, 2022 at 9:06 AM Changkun Ou wrote: > I think the new memory model does not guarantee this program always prints > 1: > > 1. There is no synchronization guarantee between line 13 and line 14 > as these atomic operations are manipulated on the different memory > locations. > Yes, t

Re: [go-nuts] About Go 1.19 memory model clarificaitons on atomic operations.

2022-08-15 Thread Changkun Ou
I think the new memory model does not guarantee this program always prints 1: 1. There is no synchronization guarantee between line 13 and line 14 as these atomic operations are manipulated on the different memory locations. 2. It is *not* prohibited for the compiler to switch line 13 and line 14

Re: [go-nuts] About Go 1.19 memory model clarificaitons on atomic operations.

2022-08-14 Thread 'Axel Wagner' via golang-nuts
Why wouldn't it? > If the effect of an atomic operation A is observed by atomic operation B, > then A is synchronized before B. To me, it seems pretty clear that it will. Line 13 is synchronized before line 14, which is synchronized before any load observing its effects (i.e. any execution of lin

[go-nuts] About Go 1.19 memory model clarificaitons on atomic operations.

2022-08-14 Thread tapi...@gmail.com
By the latest version of Go Memory Model article: https://go.dev/ref/mem, will the following program always print 1? https://go.dev/play/p/RICYGip5y8M -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop recei