'When is lock free programming faster and slower than lock/mutex based programming?

Hi I learned that lock free programming is able to give each thread freedom to decide its own progress. In other words, a thread’s progress is not affected by other threads if it chooses so.

But let’s step aside from flexibility and only talks about performance, meaning how fast the entire program runs, then which one is faster under what conditions: lock free programming or lock/mutex based programming?

Thanks.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source