From the code review (of one of the cpu units / not checked others).
It checks if you app is multi threaded, if not it does a normal "decrement by one". If yes, then it does a "locked" decrement.
"locked" here means: thread save.
If 2 threads do "Somevalue := Somevalue - 1" (or +1 / or other op), then both threads need to read the memory into a register, perform the op, and write it back to mem.
The following can happen:
- Thread1 read
- Thread2 read (the same value, thread 2 has not yet written back)
- Thread1 decrement register
- Thread1 write back
- Thread2 decrement register
- Thread2 write back
In the last step, Thread2 overwrites the value of Thread1. All together the value will have gone down by only ONE. Even though both threads should have decremented it by 1 and it should be down by TWO.
"locked" ops avoid that => but they are slower.