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

Add singlethreaded (compiler-only) fences. #888

Merged
merged 2 commits into from
Apr 6, 2015

Conversation

tari
Copy link
Contributor

@tari tari commented Feb 19, 2015

@pythonesque
Copy link
Contributor

This seems pretty useful, +1.

@reem
Copy link

reem commented Feb 20, 2015

Agreed.

@oli-obk
Copy link
Contributor

oli-obk commented Feb 20, 2015

alternatives: using black_box instead. parameters to black_box are not moved after results of black_box. allows fine-grain fences. drawback: not as easy to use

@brson brson self-assigned this Mar 5, 2015
@brson
Copy link
Contributor

brson commented Mar 12, 2015

Why does the llvm reference say 'this is useful for interacting with signal handlers'? Reading the docs for atomic_signal_fence does not enlighten.

@tari
Copy link
Contributor Author

tari commented Mar 12, 2015

My understanding is that signals preempt the thread or process receiving them, meaning they will execute on the same physical thread. Because there's no hardware context switch, memory reordering is not a concern since operations always appear to happen in program order within a single thread's context.

If code interacts with signal handlers via memory, compiler reordering of memory operations may change the order of operations as seen by the signal handler (which the compiler is not aware of), potentially violating program-maintained invariants.


Neglected to mention it elsewhere; this RFC comes from Rust PR #22358, which includes an implementation.

@brson brson merged commit b9f0c27 into rust-lang:master Apr 6, 2015
@brson
Copy link
Contributor

brson commented Apr 6, 2015

Accepted. Tracking bug rust-lang/rust#24118. Sorry for the long delays.

bors added a commit to rust-lang/rust that referenced this pull request Apr 8, 2017
Add safe wrapper for atomic_compilerfence intrinsics

This PR adds a proposed safe wrapper for the `atomic_singlethreadfence_*` intrinsics introduced by [RFC #888](rust-lang/rfcs#888). See #41091 for further discussion.
@Centril Centril added the A-intrinsic Proposals relating to intrinsics. label Nov 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-intrinsic Proposals relating to intrinsics.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants