boost无锁队列官方文档(转)

 

一哥们翻译的boost的无锁队列的官方文档

 

原文地址:http://blog.csdn.net/great3779/article/details/8765103

 

Boost_1_53_0终于迎来了久违的Boost.Lockfree模块,本着学习的心态,将其翻译如下。(原文地址:http://www.boost.org/doc/libs/1_53_0/doc/html/lockfree.html

 

Chapter 17. Boost.Lockfree

第17章.Boost.Lockfree

Table of Contents

目录

Introduction& Motivation

简介及动机

Examples

例子

Rationale

解释

DataStructures

数据结构

MemoryManagement

内存管理

ABAPrevention

ABA预防

InterprocessSupport

进程间支持

Appendices

附录

FutureDevelopments

未来发展

Introduction& Motivation

简介和动机

Introduction & Terminology

简介及术语

The term non-blocking denotes concurrent data structures,which do not use traditional synchronization primitives like guards to ensurethread-safety. Maurice Herlihy and Nir Shavit (compare "TheArt of Multiprocessor Programming")distinguish between 3 types of non-blocking data structures, each havingdifferent properties:

术语无阻塞表示并发数据结构,它们不使用传统同步原语例如守卫者来保证线程安全。MauriceHerlihy和NirShavit(相比多处理器编程艺术)区分了三种类型的无阻塞数据结构,每种均具有不同的特性:

  • data structures are wait-free, if every concurrent operation is guaranteed to be finished in a finite number of steps. It is therefore possible to give worst-case guarantees for the number of operations.
  • 无等待数据结构,如果所有并发操作都保证会在有限步骤内完成。因此就有可能给出一个对操作数目的最坏保证。
  • data structures are lock-free, if some concurrent operations are guaranteed to be finished in a finite number of steps. While it is in theory possible that some operations never make any progress, it is very unlikely to happen in practical applications.
  • 无锁数据结构,如果一些并发操作保证在有限步骤内完成。虽然理论上有些操作可能不会有任何进展,但实际应用中基本不太可能发生。
  • data structures are obstruction-free, if a concurrent operation is guaranteed to be finished in a finite number of steps, unless another concurrent operation interferes.
  • 无梗阻数据结构,如果除非被另外一个并发操作干预,否则一个并发操作保证在有限步骤内完成。

Some data structures can only be implemented in a lock-freemanner, if they are used under certain restrictions. The relevant aspects forthe implementation of boost.lockfreeare thenumber of producer and consumer threads. Single-producer (sp) or multiple producer (mp) means that only a single thread ormultiple concurrent threads are allowed to add data to a data structure. Single-consumer (sc) or Multiple-consumer (mc) denote the equivalent for the removalof data from the data structure.

如果使用在一定的限制条件下,一些数据结构只能被无锁的方式实现。与boost.lockfree实现相对应的是生产者线程和消费者线程的数目。单生产者(sp)多生产者(mp)意味着只有一个线程或多个并发线程被允许添加数据至某数据结构中。单消费者(sc)多消费者(mc)则对应于从数据结构中移除数据。

Properties of Non-Blocking Data Structures

无阻塞数据结构的性质

Non-blocking data structures do not rely on locks and mutexes toensure thread-safety. The synchronization is done completely in user-spacewithout any direct interaction with the operating system [4].This implies that they are not prone to issues like priority inversion (alow-priority thread needs to wait for a high-priority thread).

无阻塞数据结构不依赖于锁和互斥量来保证线程安全。同步完全在用户空间中完成,而不需要与操作系统的任何直接交互。这意味着它们不容易出现例如优先反转(低优先级线程需要等待高优先级线程)等问题。

Instead of relying on guards, non-blocking data structures require atomicoperations (specificCPU instructions executed without interruption). This means that any threadeither sees the state before or after the operation, but no intermediate statecan be observed. Not all hardware supports the same set of atomic instructions.If it is not available in hardware, it can be emulated in software usingguards. However this has the obvious drawback of losing the lock-free property.

无阻塞数据结构需要原子操作(特定的CPU执行指令不中断)而不是依赖于“卫兵”。这意味着任何线程只能看到操 作之前或之后的状态,而不能观察到任何中间状态。不是所有的硬件都支持同样的原子指令集。如果硬件上不支持,则可以在软件上使用“卫兵”来模拟。但这因为 失去了无锁的性质而具有明显的缺陷,。

Performance of Non-Blocking Data Structures

无锁数据结构的性能

When discussing the performance of non-blocking data structures,one has to distinguish between amortized and worst-case costs. The definition of 'lock-free'and 'wait-free' only mention the upper bound of an operation. Thereforelock-free data structures are not necessarily the best choice for every usecase. In order to maximise the throughput of an application one should conside

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值