Skip to content

Value types immune from thread racing because of this? #83938

Answered by Clockwork-Muse
Xyncgas asked this question in Q&A
Discussion options

You must be logged in to vote

There's two different definitions of "atomic" being referenced here.

The first, and better-known definition, is "operation" atomicity, which is what @svick is referring to (and everybody else seems to be as well). This requires locks or Interlocked. The catch is that you need multiple operations to be atomic, and addition is one operation... and read and store are two additional operations. This is mostly constant across all versions and platforms.

The second, not as commonly known, is "storage" atomicity, which depends heavily on processor, most usually on bit-width. This is where, if you had multiple threads trying to store a value, you could get some bits from one thread and some bits …

Replies: 4 comments 7 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@Clockwork-Muse
Comment options

Comment options

You must be logged in to vote
6 replies
@huoyaoyuan
Comment options

@Xyncgas
Comment options

@Clockwork-Muse
Comment options

@Xyncgas
Comment options

@Clockwork-Muse
Comment options

Answer selected by Xyncgas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants