A developer is evaluating atomic functions to protect shared counters in a multithreaded service. Which statements describe atomic operations? (Choose four.)
Choose 4 answers
Show the answer
Correct answersA. They are often implemented with CPU instructions such as compare-and-swapB. Concurrent updates to a shared counter do not corrupt its valueC. Other threads never see a half-completed updateE. The operation either completes fully or has no effect
AWhy this is right: Hardware primitives such as compare-and-swap are a common way to build atomic operations.
BWhy this is right: Because each update is indivisible, simultaneous updates cannot interleave and corrupt the counter.
CWhy this is right: Indivisibility means no other thread can observe an intermediate state.
DWhy not this: Checking buffer lengths is a memory-safe function property, not atomicity.
EWhy this is right: Atomicity is all-or-nothing: the operation finishes completely or leaves no effect.
FWhy not this: Rejecting malformed data is input validation, which is unrelated to atomicity.
Atomic operations are indivisible: no intermediate state is visible, they succeed fully or not at all, they commonly rely on hardware instructions like compare-and-swap, and they keep shared values consistent. Bounds checking belongs to memory-safe functions, and format checking to input validation.