Multicore & Synchronization
Which describes an atomic instruction?
- AAn instruction that performs a memory read and write as a single operation that no other core can interrupt partway
- BAn instruction for physics calculations that counts atoms
- CThe fastest instruction, always finishing in one clock
Show answer and explanation
Answer: A. An instruction that performs a memory read and write as a single operation that no other core can interrupt partway
An atomic instruction performs a read, compute and write sequence such that no other core's access can come in between. Other cores see only the state before or after the operation. Examples include CAS (compare-and-swap), fetch-and-add and RISC-V's LR/SC and AMO instructions, which are the building blocks of locks and lock-free data structures.
- A. Correct. To other cores it appears to happen instantaneously.
- B. Atomic here means indivisible.
- C. Its defining feature is indivisibility, not speed.