0

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.

kesari
  • 536
  • 1
  • 6
  • 16

2 Answers2

2

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.

Community
  • 1
  • 1
Richard
  • 106,783
  • 21
  • 203
  • 265
1

There are two concepts at work here:

1) Atomic instructions are those that a processor cannot interrupt.

2) Interlocked instructions are those that lock the memory bus and invalidate [sections of] the CPU caches.

An interlocked instruction will always be atomic. An atomic instruction might not be (and often is not) interlocked.

user3344003
  • 20,574
  • 3
  • 26
  • 62