文件名称:多核编程入门
文件大小:1.82MB
文件格式:PDF
更新时间:2016-11-06 05:20:26
java 多核 并发
一. 并发与并行的区别? ........................................................................................................................... 1 1.1 串行 .................................................................................................................................................. 1 1.2 并发 .................................................................................................................................................. 1 1.3 并行 .................................................................................................................................................. 1 1.4 多核编程的难点 ............................................................................................................................... 2 二. 多核体系架构 ...................................................................................................................................... 3 2.1 多核处理器定义 ............................................................................................................................... 3 2.2 多核发展趋势 .................................................................................................................................. 3 2.3 一个多核处理器架构例子 ............................................................................................................... 5 2.4 LINUX 线程核绑定 .............................................................................................................................. 6 2.4.1 核亲和性绑定 ........................................................................................................................... 6 2.4.2 资源控制 cgroup ...................................................................................................................... 8 三. 内存模型 .............................................................................................................................................. 8 3.1 操作原子性 ...................................................................................................................................... 9 3.1.1 原子性的3种保证机制 ........................................................................................................... 9 3.1.2 硬件原子操作 ........................................................................................................................... 9 3.1.3 总线锁-原子操作原语 ............................................................................................................ 12 3.2 缓存一致性 .................................................................................................................................... 16 3.2.1 定义 ........................................................................................................................................ 16 3.2.2 CC协议 .................................................................................................................................... 17 3.2.3 伪共享 .................................................................................................................................... 21 3.3 顺序一致性 .................................................................................................................................... 24 3.3.1 定义 ........................................................................................................................................ 24 3.3.2 几种顺序约束 ......................................................................................................................... 25 3.3.3 乱序执行和内存屏障 ............................................................................................................. 28 四. 并发级别 ............................................................................................................................................ 31 4.1 WAIT-FREEDOM 无等待并发 .............................................................................................................. 32 4.2 LOCK-FREEDOM 无锁并发 ................................................................................................................... 32 4.3 OBSTRUCTION-FREEDOM 无阻塞并发 .................................................................................................. 33 4.4 BLOCKING ALGOITHMS 阻塞并发 .......................................................................................................... 33 五. 锁 ....................................................................................................................................................... 34 5.1 信号量 ............................................................................................................................................ 34 5.2 自旋锁 ............................................................................................................................................ 35 5.3 读写锁 ............................................................................................................................................ 35 5.4 顺序锁 ............................................................................................................................................ 37 5.5 RCU .................................................................................................................................................. 38 六. 无锁编程 ............................................................................................................................................ 38 6.1 定义 ................................................................................................................................................ 39 七. 并发数据结构、开源库 ..................................................................................................................... 41 7.1 一些开源的并发库 ......................................................................................................................... 41 7.2 一次无锁哈希表跟基于锁的哈希表性能对比测试 ..................................................................... 41 7.2.1 测试平台 ................................................................................................................................ 41 7.2.2 测试过程 ................................................................................................................................ 42 7.2.3 哈希算法 ................................................................................................................................ 43 7.2.4 测试结果 ................................................................................................................................ 44 八. 多核工程实践 .................................................................................................................................... 44 8.1 网络设备 :INTEL DPDK .................................................................................................................. 44 8.2 网络游戏 ........................................................................................................................................ 44 8.3 手机开发 ........................................................................................................................................ 45 九. 参考 ................................................................................................................................................... 45