Skip to content
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

Missing memory fences in mutexes #53

Open
socketpair opened this issue May 3, 2021 · 2 comments
Open

Missing memory fences in mutexes #53

socketpair opened this issue May 3, 2021 · 2 comments

Comments

@socketpair
Copy link

https://en.m.wikipedia.org/wiki/Memory_barrier#Multithreaded_programming_and_memory_visibility

You need mfence/lfence/sfence before mutex_lock() returns, and before unlock() returns.

@socketpair
Copy link
Author

Thread 1:
Lock
A=1
Unlock

Thread 2:
Lock
Read A. May see old, not updated by thread 1 value.

@nemasu
Copy link
Owner

nemasu commented Mar 4, 2024

Thanks for this! Sorry for the incredibly late response. The mutex isn't being used at the moment, but I'll try to add these system calls anyways though just so it's usable if it's ever needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants