January 2019
Intermediate to advanced
384 pages
11h 50m
English
If we are sparing a kernel trip, this is a clear win, so we want to use it everywhere!
No so fast. First, we already mentioned that taking an uncontended mutex is a fast operation and the kernel trip is only needed if there is a contention. Second, the attentive reader will surely notice one big problem with CAS—yes, we are spinning, thus burning CPU power and exacerbating the contention even more!
We must mention that modern Intel processors have a special PAUSE instruction which can be added to the body of the spin and provide a hint to the CPU that the code being executed is a spin-wait loop. This will improve the performance of the spin somehow. We could further reduce spinning costs by using an exponential ...
Read now
Unlock full access