Search code examples
operating-systematomicmulticore

Atomic Instructions | Maintain Data Consistency


Atomic instructions are those which execute as a whole and cannot be interrupted.

Is it also necessary that the data it operates on isn't manipulated during execution ?, i.e. an instruction executing on another core accessing the atomic instruction's data.

I'm currently enrolled in the "Operating Systems" course at my college.


Solution

  • Is it also necessary that the data it operates on isn't manipulated during execution ?

    Yes.

    And that is why such instructions can be expensive to execute, possibly taking hundreds of cycles and including lock the CPUs' busses and checking no other CPUs (not just other cores: multi-socket systems have to be included) are accessing the affected memory.

    See also this answer.