New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to imply memory barrier in go? #43031
Comments
You should not need a fence to make that work. If an Can you show us a full program that demonstrates the problem? Make sure you're obeying the restrictions on |
Full program is:
I checked the disassembly of Read:
It seems function |
This is not a complete program that I can run. There's no The |
What version of Go are you using (
go version
)?What operating system and processor architecture are you using (
go env
)?amd64
What did you do?
I implemented an inter-process shared memory queue with Golang.
I use an
atomic.Value
as an IPC mutex, but has problem on memory access sequence.eg:
process 1 has:
process 2 has:
What did you expect to see?
the
*ptr
should always be 1, but it sometimes can be 0.Should I use assembly smb() or sth to ensure the correct order?
Is there some function like C++
std::atomic_thread_fence
in golang?The text was updated successfully, but these errors were encountered: