5 ms·
Lots of code is 'lock free' and uses the same pattern (more or less). Attempt the change optimistically, if it fails spin it, if it keeps failing (Massive Conte
by xxs 2y ago
Lots of code is 'lock free' and uses the same pattern (more or less). Attempt the change optimistically, if it fails spin it, if it keeps failing (Massive Contention), back off.
- adastra22 2y agoA properly lock-free architecture wouldn’t have spin-locks, no?
- xxs 2y agoof course, no lock. I have written quite the fair share of lock free code (back then when it was new), and generally enjoy writing it (to this day). Yet, for most folks it's just too hard to reason/understand/maintain it. Just a note, lock free is a lesser requirement than wait-free.
- pjdesno 2y agoA properly lock-free architecture is a spin-lock :-)
- xxs 2y agospin locks prevent forward grantees, e.g. when the thread is scheduled out (or serves an interrupt), no other thread can make progress. Lock free allows progress - there is no exclusivity. Of course if working on the kernel and controlling the scheduler, etc. the restriction does not apply immediately. Realistically though, lots of lock free employs copy-on-write or rcu.