How do atomic operations work, under the hood?
Are atomic operations so-called “wait-free”?
I’m seeking for a description of the “least common divisor” of atomic operations. What do all atomic operations share?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Atomicity as a concept occurs in several places, I suspect you’re thinking about atomic operations in code, but there are other meanings.
One fundamental property of a Database transaction is Atomicity, see a description of ACID properties of transactions.
In this case, you have lots of database cleverness, locks, and so on, which almost certainly imply waiting when two threads of control (or two processes) want to get at the same data.
When you come to lines of code I guess you’re thinking about a declaration (in some fictitious language)
in one thread
and in another
Can we say anything about what the second thread will print? We might accept either 7 or 25000, we’d be less happy to get a number that was the high order byte of 25,000 and a low order byte of 7 – which conceptually would be the result of a non-atomic integer assignment.
Different programming languages are free to define whatever semantics they wish, it’s conceivable that some would just accept whatever natural behaviors that the CPU they work on (say 32-bit int was atomic, 64 long was not) or they might do something much cleverer, and if the CPU itself doesn’t provide atomic operations then I don’t see much alternative to some kind of waiting if they want to fake atomicity – eg. Java synchronized keyword.