Re:Lock-free multithreading with atomic operations
by gpderetta on Tuesday July 30, 2019 @07:18AM
(#20563766)
Even to main memory there is not necessarily a single memory bus. Intracore or even intrasocket synchronization need not (and usually doesn't) go through main memory anyway.
[ Parent
| on HN ]
Re:Lock-free multithreading with atomic operations
by amelius on Tuesday July 30, 2019 @08:07AM
(#20564058)
True, but some atomic instructions may need to access main memory to complete their operation. Whether shortcuts can be taken in most cases is not relevant for worst-case considerations.
Re:Lock-free multithreading with atomic operations
by bonzini on Tuesday July 30, 2019 @10:43AM
(#20565233)
They may need to access main memory, but the RMW operation don't happen over the memory bus. The processor appropriates the cache line just like any other memory access, and then operates atomically on the cache line.
Re:Lock-free multithreading with atomic operations
by amelius on Tuesday July 30, 2019 @01:03PM
(#20566804)
And what if the cache line is full/dirty?
Re:Lock-free multithreading with atomic operations
by bonzini on Tuesday July 30, 2019 @02:20PM
(#20567629)
The cache coherency protocol takes care of that. In other words the first part is just a memory load and can vary from 0 to a few hundred clock cycles, the second is local to the processor and has a more or less fixed cost. The worst-case execution time is completely dominated by the first part, the best case instead is dominated by the second.
Re:Lock-free multithreading with atomic operations
by jasonwatkinspdx on Tuesday July 30, 2019 @03:47PM
(#20568431)
I'd suggest reading the wiki articles about it for an introduction, and Ch 5 of https://www.amazon.com/Computer-Architecture-Quantitative-Jo... for a detailed understanding.
Right now you're asserting things about all this, while not being familiar with relatively basic aspects of how it works.