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

Current atomics are not defined to be lock-free #32967

Closed
brson opened this issue Apr 14, 2016 · 4 comments
Closed

Current atomics are not defined to be lock-free #32967

brson opened this issue Apr 14, 2016 · 4 comments
Labels
C-feature-request Category: A feature request, i.e: not implemented / a PR. T-lang Relevant to the language team, which will review and decide on the PR/issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@brson
Copy link
Contributor

brson commented Apr 14, 2016

Right now we define things like AtomicPtr unconditionally. On platforms without real atomics these get lowered to locks today. People write lock-free algorithms with these atomics that are not actually guaranteed to be lock free.

For comparison, I'm told (by @sunfish) that C++ does try to guarantee that atomics are lock-free.

cc rust-lang/rfcs#1543

@codyps
Copy link
Contributor

codyps commented Apr 14, 2016

C++ (and C11) makes no guarantee of it's atomics (in general) being lock-free. Only atomic_flag is guaranteed to be lock free. All other atomic<T> variants are allowed to be implemented by locks.

Previous discussion around this can be seen in rust-lang/rfcs#1505

@brson
Copy link
Contributor Author

brson commented Apr 15, 2016

@jmesmon Ah, you are right. There is an api for asking whether atomics are lock free.

@Amanieu
Copy link
Member

Amanieu commented Apr 15, 2016

The plan with rust-lang/rfcs#1543 is to only expose atomic types which are guaranteed to be lock-free. Non-lock free atomic types can then be built on top of those, like I did in the atomic-rs library.

@steveklabnik steveklabnik added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. T-lang Relevant to the language team, which will review and decide on the PR/issue. and removed A-libs labels Mar 24, 2017
@Mark-Simulacrum Mark-Simulacrum added C-enhancement Category: An issue proposing an enhancement or a PR with one. C-feature-request Category: A feature request, i.e: not implemented / a PR. and removed C-enhancement Category: An issue proposing an enhancement or a PR with one. labels Jul 25, 2017
@dtolnay
Copy link
Member

dtolnay commented Nov 18, 2017

I believe this is being tracked in #32976, as it is the thing currently blocking stabilization of the atomic types from rust-lang/rfcs#1543.

@dtolnay dtolnay closed this as completed Nov 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: A feature request, i.e: not implemented / a PR. T-lang Relevant to the language team, which will review and decide on the PR/issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

6 participants