Disruptor
The complexities of Concurrency
Concurrent execution of code is about two thing:
- mutual exclusion
- visibility of change
The costs of CAS
- A CAS operation is a special machine-code instruction that allows a word in memory to be conditionally set as an atomic.
- This CAS approach is significantly more efficient than locks because it does not require a context switch to the kernel for arbitration.
- However CAS operations are not free of cost. The processor must lock its instruction pipeline to ensure atomicity and employ a memory barrier to make the changes visible to other threads.