3 ms·
Historically, the right limit for a loop around a spin lock/CAS was related to the effective time cost of a context switch (taking into account both the registe
by PaulDavisThe1st 2y ago
Historically, the right limit for a loop around a spin lock/CAS was related to the effective time cost of a context switch (taking into account both the register save/restore and TLB flush). This is not a fixed number across all hardware but it is knowable upper bound.
- manmal 2y agoThat’s an interesting perspective. I‘m not sure I‘d ever be able to act on this outside of some embedded environments - even there, we now have actual OSs and the variance that comes with them.
- PaulDavisThe1st 2y agoContext switches on most general purpose OS's are non-preemptible. It's relatively easy to find out what they cost. The TLB hit is application dependent - it depends on the working set (memory use footprint) after the switch. This is not some hard to know thing, certainly not for the purposes of bounding a spinlock.