2 ms·
There is a third reason to go lock free: You cannot take locks or wait. I've had some cases in embedded devices and OS development where taking a lock is not p
by zaarn 7y ago
There is a third reason to go lock free: You cannot take locks or wait.
I've had some cases in embedded devices and OS development where taking a lock is not possible.
One example might be read buffer in an embedded device that is on one end being fed from an interrupt routine and on the other being consumed by a normal processor routine.
The interrupt routine can happen at any time the normal processor routine happens and it cannot wait or yield to it since there is only one core and no task scheduling. It needs to write to the buffer now, regardless of what the consumer is doing.
Lock-free has some desirable properties, it can run concurrently on single-core machines in presence of interrupts and it's safely reentrant.