Lock-free Programming
Lock-free programming is a technique that allows concurrent updates of shared data structures without the need to perform costly synchronization between threads. This method ensures that no thread block for arbitrarily long time, and it guarantees progress.
Lock-free algorithms carefully design data structures and functions to allow for multiple threads to make progress independently from one another. This means that you do not try to acquire a lock before entering your critical region. Instead, you independently maintain a local copy of (a portion of) the data structure and then apply it atomically to the shared structure with a CAS instruction (Compare-And-Swap).
Lock-free programming has the following advantages:
it can be used in places where locks must be avoided, such as within interrupt handlers;
it avoids the trouble of blocking, such as deadlock and priority inversion;
it improves performance on a multi-core processor.
Now, let's begin to design a lock-free data structure.
Last updated
Was this helpful?