What's the difference between lockless and lockfree?

前端 未结 2 650
不知归路
不知归路 2021-01-04 21:01

In some articles about algorithm, some use the word lockfree, and some use lockless. What\'s the difference between lockless and

2条回答
  •  鱼传尺愫
    2021-01-04 21:18

    An algorithm is lock-free if it satisfies that when the program threads are run sufficiently long at least one of the threads makes progress (for some sensible definition of progress). All wait-free algorithms are lock-free.

    In general, a lock-free algorithm can run in four phases: completing one's own operation, assisting an obstructing operation, aborting an obstructing operation, and waiting. Completing one's own operation is complicated by the possibility of concurrent assistance and abortion, but is invariably the fastest path to completion. e.g. Non blocking algorithms

    Lockless programming, is a set of techniques for safely manipulating shared data without using locks. There are lockless algorithms available for passing messages, sharing lists and queues of data, and other tasks. Lockless programming is pretty complicated. e.g. All purely functional data structures are inherently lock-free, since they are immutable

提交回复
热议问题