Re: [go-nuts] Why doesn't Go use atomic.LoadInt32() in sync.Mutex.lockSlow()?

2022-04-03 Thread liweiforeveryoung
Thanks for your reply,Ian.I've always had a misunderstanding about atomic operation,I thought atomic operation is only used to protect the CPU instructions from being interrupted. I have watched some lectures about C++ memory order on youtube.As you mentioned,another function of atomic operat

Re: [go-nuts] Why doesn't Go use atomic.LoadInt32() in sync.Mutex.lockSlow()?

2022-04-03 Thread liweiforeveryoung
Thanks for your reply,eric.I've always focused on this situation,without atomic operator,If goroutine A set a variable v to 0 and goroutine B set the variable a to 1,anther goroutine C would probably get a unexpected value which is neither 0 nor 1 when its read operation of a is interrupted.S